A simple password strength checker.
jsxCopy codeimport React, { useState } from 'react';
import ReactDOM from 'react-dom';
function PasswordStrengthChecker() {
const [password, setPassword] = useState('');
const getStrength = () => {
if (password.length < 6) return 'Weak';
if (password.length < 12) return 'Moderate';
return 'Strong';
};
return (
<div>
<h1>Password Strength Checker</h1>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
placeholder="Enter your password"
/>
<p>Password strength: {getStrength()}</p>
</div>
);
}
ReactDOM.render(<PasswordStrengthChecker />, document.getElementById('root'));
Leave a Reply