Source Code:
(back to article)
Submit
Result:
Report an issue
<div> <pre> <input type="password" id="passwordInput" placeholder="Enter your password"> <div id="passwordStrength"></div> <script> document.getElementById('passwordInput').addEventListener('input', function(event) { var strength = event.target.value.length; var strengthMessage = 'Weak'; if(strength > 5) strengthMessage = 'Moderate'; if(strength > 10) strengthMessage = 'Strong'; document.getElementById('passwordStrength').textContent = 'Strength: ' + strengthMessage; }); </script> </pre> </div>