View Single Post
Old 09-19-2012, 08:15 PM   PM User | #4
philmccollam
New to the CF scene

 
Join Date: Sep 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
philmccollam is an unknown quantity at this point
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
philmccollam is offline   Reply With Quote