Welcome to WebmasterWorld Guest from 54.162.155.183

Forum Moderators: open

Message Too Old, No Replies

JavaScript age verification

     
9:22 am on May 6, 2002 (gmt 0)

10+ Year Member



Hi,

This is an age verification script. It works using alerts. I basically want t oknow how to alter it so that once the correct age is typed in, it will just go straight to the homepage and not bring up a welcome alert. Any help appreciated.

I have already been given an answer...but it never worked. Try it to see how it works.

<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>

Regards
webboy

9:29 am on May 6, 2002 (gmt 0)

10+ Year Member



Try this:

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

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

}
</script>

This should send a person to 'ok-page.html' if they are 18 or over, but to too-young-page.html' if they are too young.

9:32 am on May 6, 2002 (gmt 0)

10+ Year Member



You may also like to look into the use of cookies so your page will remember what they entered and the next time they return, automatically send them to the right page without entering their age again.

I'm no good at cookies on Unix servers but fine on IIS/ASP pages. I'm sure someone here will be able to to help you out with it though if you're on a Unix host.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month