Hmm....I made a bit progress. I am trying to code simillar exercise.
In this exercise, user input word in the text box. Then prompt box ask user to reenter the word. If the twos are same, print "thanks for log in" otherwise user can try up to 4 times then if fails, alert says none of your business.
Please see my code below:
code:
<html>
<head>
<script type="text/javascript">
function logIn(){
var Pass=document.theForm.pass.value;
var ans=0;
var i=0;
while(i<=3){
if(Pass!=ans){
ans=prompt("Re-enter the password again");
}else{
document.write("thanks for your log in!");
}
i++;
}
if(ans != Pass){
alert("None of your business");
}
}
</script>
</head>
<body>
<form name="theForm">
<p>
Enter your password:
<input type="password" name="pass">
<p />
<p>
<input type="button" value="Submit" onClick="logIn()">
<input type="reset" value="Reset">
</p>
</form>
</body>
</html>
Here is uploaded file2.
There is two problem.
1.In the prompt box, if user clicks "calcel", ,message "thanks for log in" is printed.
2.When input everything colletly, "thanks for log in" is printed coule of times. I wanted jsut once.
Hhmm.....Would you know how to control cancel button of prompt box? And how to stop printing same statement???
Hiroki Kozai