Program:
Output:
<!DOCTYPE html> <html> <head> <script type='text/JavaScript'> function validate() { var pass = document.getElementById("pass").value; var strongRegex = new RegExp("^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#\$%\^&\*])(?=.{8,})"); var mediumRegex = new RegExp("^(((?=.*[a-z])(?=.*[A-Z]))|((?=.*[a-z])(?=.*[0-9]))|((?=.*[A-Z])(?=.*[0-9])))(?=.{6,})"); if(strongRegex.test(pass)) { document.getElementById("e").innerText =" Strong Password "; } else if(mediumRegex.test(pass)) { document.getElementById("e").innerText =" Medium Password "; } else { document.getElementById("e").innerText =" Weak Password "; } } </script> </head> <body> <form> Enter Password: <input type="password" id="pass" onkeyup="validate()"> <p id = "e"> </p> </form> </body> </html>
Output: