html - Confirming password using JavaScript -
i need in making webpage.
when user types password, want statement 'the password not same' in part. don't understand wrong code.
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <title> login page </title> </head> <body> <form action="login_2.php" method="post"> <input type="hidden" name="action" value="login"> <input type="hidden" name="hide" value=""> <table class='center'> <tr><td>login id:</td><td><input type="text" name="id"></td></tr> <tr><td>password:</td><td><input type="password" name="password"></td></tr><br> <tr><td>confirm_password: </td><td><input type="password" name="confirm_password" onkeyup="test();"></td></tr><br> <tr><td><div id="pwd" style="height: 35px;"></div></td></tr> <tr><td>full name: </td><td><input type="text" name="name"></td></tr> </form> <script> function test(){ if(document.info.password.value != document.info.confirm_password.value){ document.getelementbyid('pwd').innerhtml='wrong'; }else{ document.getelementbyid('pwd').innerhtml='continue'; } } </script> </table> <tr><td> </td><td><input type="submit" value="login"></td></tr> </body> </html>
since there no id's on input fields can change document.info document.getelementsbyname
function test(){ if(document.getelementsbyname("password")[0].value != document.getelementbyid("confirm_password")[0].value){ document.getelementbyid('pwd').innerhtml='wrong'; }else{ document.getelementbyid('pwd').innerhtml='continue'; } }
Comments
Post a Comment