What is the code for condition if – i know, what its in PHP, for demonstartion:
if($pass == "/secret password/") {}
How i can write this in javascript?
EDIT: Wow, many thanks for answers, i went to test it, but here is one mystake, i don’t know, how i can get value of text input into variables (in ajax)
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:
Javascript:
And, lastly, please do NOT build a web page that checks a password in this way as it is very insecure.