[Solved] javascript if condition [closed]


First off, as others have said, you should NEVER be testing the value of a password in client-side javascript because to do so requires that you have the correct value of the password embedded in the source of your web page. That is completely hackable merely by viewing the code for the page. It’s OK to check for min length, mix of chars, etc…, but the value of a password must always be submitted to your server and checked on the server. Only then does the password provide ANY level of security.

Then, to respond to your recent edit, to get a value from an input field, you would do the following:

HTML:

<input id="myField" type="text">

Javascript:

if (document.getElementById("myField").value == "whatever") {
    // value is as expected
}

And, lastly, please do NOT build a web page that checks a password in this way as it is very insecure.

0

solved javascript if condition [closed]