Skip to content Skip to sidebar Skip to footer

How To Check What Tag Says For A Password

I'm trying to make a sign-in page for my website and I wanted to make a input for my password system. I've used the prompt() solution but it is not very efficient. Copy

2) Now that I have the onclick, I need to make my function

functionmyfunction() {
        var pass = document.getElementById("passwordInput"); 

        //this returns the value of input
    }

3) I now need to check if the password is right so I add this to myfunction()

if(pass.value == "correct password") {
       alert("You have logged successfully")
    }

One good website to find out how to make a login page is https://getcodingkids.com/code-skill/create-a-password/

Solution 2:

<script>functioncheckpassword() {
  var password = document.getElementById("password");
  var pass = password.value;
  if(pass == "admin"){
     alert("Correct!");
  }
}
<script>
<inputtype="password"id="password"placeholder="Password"><buttononclick="return checkpassword()">Login</button>

Solution 3:

Use basic if statements.

HTML

<inputtype="password"id="password" placeholder="Enter Password.."/>
<inputtype="button" value="Login" name="login" onclick="checkPass(document.getElementById('password').value)"/>

JAVASCRIPT

function checkPass(pass){
    if(pass == "correct pass"){
        alert("Access Granted");
    }
    else {
        alert("Please check your password");
    }
}

Post a Comment for "How To Check What Tag Says For A Password"