Thanks for the help! I agree that the prompt() is not the best way to do it, so I set up a new version that should use text input to verify the age of the user. However, I'm not versed in script well enough to make it actually function.
Here is what I have now: (also viewable at
http://philrules.com/17-tips/week-16/)
Code:
$(window).load(function verify() {
var ageNum=parseInt(document.forms["age-verification"]["age"].value);
var randomNumber=Math.floor(Math.random()*31)
if (ageNum==null || ageNum=="") {
return false;
}
else {
if (ageNum>=randomNumber)window.location.href="too-old.htm";
else {
window.location.href="take-a-seat.htm";
}
}
});
The form I have set up to interact with this script is:
Code:
<form name="age-verification" onSubmit="verify()";>
<label>Age</label>
<input name="age" type="text" size="3" maxlength="2">
<input name="Submit" type="Submit">
</form>
My apologies if this is all syntactically horrendous; I'm still learning the language.
Best,
Phil