i need help creating a password form in html/javascript -


i trying make password field , not working, if knew wrong with
code (probably because second project) grateful.

    <!doctype html> <html lang="en">     <head>         <meta charset="utf-8">          <title>password</title>         <script>             (function pw_check() {   var $password;   $password = document.write(document.getelementbyid("password"));   if ($password = "pass") {window.open("alert.html");}    else {window.open("pwfail.html");};   });          </script>          <meta name="viewport" content="width=device-width; initial-scale=1.0">     </head>      <body>         <form>             <input type="password"/>             <button onclick="pw_check" id="password">submit</button>         </form>     </body> </html> 

two problems:

  1. onclick="pw_check();", otherwise you're referencing function not calling it

  2. your pw_check() function kinds of wrong. try:

    function pw_check() {     var pw = document.getelementbyid('password_input').value;     if( pw == "pass") location.href = "alert.html";     else location.href = "pwfail.html"; } 

    and change form this:

    <form>     <input type="password" id="password_input" />     <button type="button" onclick="pw_check();">submit</button> </form> 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -