homepage Welcome to WebmasterWorld Guest from 54.226.147.84
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
JavaScript age verification
webboy1

10+ Year Member



 
Msg#: 102 posted 9:22 am on May 6, 2002 (gmt 0)

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

 

JuDDer

10+ Year Member



 
Msg#: 102 posted 9:29 am on May 6, 2002 (gmt 0)

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.

JuDDer

10+ Year Member



 
Msg#: 102 posted 9:32 am on May 6, 2002 (gmt 0)

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.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved