Program:
Output:
<!DOCTYPE html> <html> <head> <style> </style> <script type='text/JavaScript'> function emailValidate() { var a = document.loginForm.user.value; var h5 = document.getElementById("email"); h5.innerHTML = a; if(a == "abc@gmail.com") { h5.innerHTML = "Correct Email ID"; return "ok"; } else { h5.innerHTML = "InCorrect Email ID"; return "not ok"; } } function validate() { var res = emailValidate(); if(res == "ok") { var pass = document.loginForm.pass.value; console.log(pass); if(pass == "abc") { alert("Login Success"); } else { alert("Login UnSuccess"); } } } </script> </head> <body> <form name="loginForm" action="" method="POST" > <fieldset> <legend> Login Details </legend> Username: <input type="text" name="user" onkeyup="emailValidate()" /> <h5 id="email"> </h5> <br/><br/> Password: <input type="text" name="pass"/> <br/><br/> <input type="submit" onclick="validate()" /> </fieldset> </form> </body> </html>
Output: