Check Password from input type password - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Password

Description

Check Password from input type password

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body>
       Password:/*from   w w w  .  ja  va2 s. com*/
      <br> 
      <input type="password" id="password"> 
      <button onclick="myFunction()">Submit</button> 
      <p id="login"></p> 
      <script>
function myFunction() {
    password = document.getElementById("password").value;
    if(password == '12345'){
      document.getElementById("login").innerHTML = "Success!";
    }else{
      document.getElementById("login").innerHTML = "Wrong password!";
    }
}

      </script>  
   </body>
</html>

Related Tutorials