View Single Post
Old 09-19-2012, 08:56 PM   PM User | #5
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,102
Thanks: 197
Thanked 2,421 Times in 2,399 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
Code:
<html>
<head>
</head>

<body>

<script type = "text/javascript">

function verify() {
var ageNum=parseInt(document.forms["age-verification"]["age"].value,10);//  if you use parseInt() youmust specify the radix
var randomNumber=Math.floor(Math.random()*31);
if (isNaN(ageNum)) {
alert ("Please enter a numeric value for age");
document.forms["age-verification"]["age"].value = "";
return false;
}

if (ageNum>=randomNumber){window.location.href="too-old.htm"}
else { window.location.href="take-a-seat.htm";  }

}

</script>

<form name="age-verification" >

<label>Age</label>
<input name="age" type="text" size="3" maxlength="2">
<input name="b1" type="button" value = "Verify" onclick = "verify()">
</form>

</body>
</html>
__________________

All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.
Philip M is offline   Reply With Quote