Forum Moderators: open

Message Too Old, No Replies

java age prompt problem

         

webboy1

10:40 am on May 2, 2002 (gmt 0)

10+ Year Member



Hi,

Sorry, this is the full age script:

<script language="javascript">
var agePrompt=prompt("You must be over 18 to enter.")

if (agePrompt>=18) alert('welcome to ....')
else {
alert('Sorry, we can not let you in!')
document.location="http://www.example.co.uk";

}
</script>

Basically the script is put on the index page of the site. Then it pops up a few alerts. How do i get it to miss the "welcome" alert, and just go straight into the site?

regards
webboy

(edited by: tedster at 6:47 pm (utc) on May 2, 2002)

joshie76

1:14 pm on May 2, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This should do the trick.

<script language="javascript" type="text/javascript">  
var agePrompt = window.prompt("You must be over 18 to enter. Please enter your age:","")
//If value entered is Not a Number or less than 18 then reject.
if (isNaN(agePrompt) ¦¦ agePrompt<18)
{
alert('Sorry, we can not let you in!')
document.location="http://www.example.co.uk";
}
</script>

Josh

(edited by: tedster at 6:47 pm (utc) on May 2, 2002)