This is originally from Web Teacher - go there to check it out and learn all about if statements.

Ask for password

You say - "But the passwords in the source code what good is that", well check out this page.

Back to examples


<HTML>
<HEAD>
<TITLE>Chapter 3, If-then statements</TITLE>

<SCRIPT LANGUAGE="JavaScript">
<!-- Beginning of JavaScript -

function password() {

Ret = prompt('Type the word castle',"");
if(Ret=="castle") {
alert("Password Correct")
}
else {
alert("Please try again")
}

}

// - End of JavaScript - -->
</SCRIPT>

</HEAD>
<BODY>

<A HREF="javascript:password()">
Ask for password</A>