This is a very old tutorial, that I felt like posting on ZFGC. It's not that I suggest you to use JavaScript for this, but more for people to practice their JavaScript skills.
---------
Password Prompt Tutorial
Requirement
- NotePad or another text edit program
- HTML Knowledge
- JS Beginner expierience
Tutorial
This turorial is about Javascript "Password Prompt's". Password prompts are prompts that looks like error messages, which has a textarea in it. In this tutorial, you'll learn how that work, and what you have to do for it.
Here you go, Run NotePad or another edit program. First, Start with a HTML Javascript code.
<script type="text/Javascript">
Then put 2 variables pass and answer. The pass variable is your pass, The answere is the prompt.
var pass = "(pass here)";
var answer = "";
The code will start with the answer prompt, Use this code to open the prompt.
answer = prompt("Enter the password to continue", "", "Enter Password");
When you're done with the answer, You need to add the password on it. Use this code. This code will check your pass in the answer.
if (answer == pass)
{
alert("Password Correct!");
alert("Access Accepted, Welcome!");
window.location = "http://(your site here)/logged.html";
}
If the pass is right, Your access would be granted. The next step is to check the password is wrong.
else if (answer != pass)
{
alert("Password Incorrect!");
alert("Access Denied, Go away!");
window.location = "http://(your site here)/login.html";
}
Otherwise, if the pass is wrong, The script will redirect you back to the login page. Then end the script.
</script>
If it's not working, Reply for questions/comments.