Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    Regular Coder
    Join Date
    Apr 2010
    Posts
    220
    Thanks
    116
    Thanked 1 Time in 1 Post

    Setting up an 'over 18' age validation w/ Javascript

    Hello, this for a tobacco website I am building. This isn't my site below - but I need to setup a age confirmation popup like this site has, with terms & conditions:

    Amsterdam | Smoke and Vape Shops

    Notice how there is no way to circumvent the URL either...the URL doesnt change even after you enter the site.

    I can set up a splash page easy enough, but need help on the rest, please

    Thanks
    J

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,145
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    This forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others (especially code that appears to be for commercial purposes), but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.

    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.

  • #3
    Regular Coder
    Join Date
    Apr 2010
    Posts
    220
    Thanks
    116
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Philip M View Post
    This forum is not a free coding service. As a general rule, the people helping out in this forum don't write code for others (especially code that appears to be for commercial purposes), but try to help with fixing code that doesn't work. You may perhaps get someone to write this script for you, but you'll be far more likely to get help if you have made a substantial effort and written some code yourself. Then someone here will almost certainly help you correct/improve your work.
    I was actually just looking for someone to point me towards a tutorial, framework, etc. This type of feature is very basic and has been done probably hundreds of different ways. But don't worry, I already found something through Google:

    function checkCheckBox(f) {
    if (f.agree.checked == false) {
    alert('Please check the box to continue.');
    return false;
    } else
    return true;
    }
    Last edited by BlackReef; 08-27-2014 at 09:14 AM.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,145
    Thanks
    203
    Thanked 2,547 Times in 2,525 Posts
    Quote Originally Posted by BlackReef View Post
    I was actually just looking for someone to point me towards a tutorial, framework, etc. This type of feature is very basic and has been done probably hundreds of different ways. But don't worry, I already found something through Google:
    alerts are considered obsolete. If you want to show a message to your users, you should use DOM methods. But I had not understood that simple script was all you wanted. I understood you to mean you wanted to make a site like the one you mentioned.

    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.

  • #5
    Regular Coder
    Join Date
    Apr 2010
    Posts
    220
    Thanks
    116
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Philip M View Post
    alerts are considered obsolete. If you want to show a message to your users, you should use DOM methods. But I had not understood that simple script was all you wanted. I understood you to mean you wanted to make a site like the one you mentioned.
    Negative. The site is already built and finished, just need this popup with age verification. DOM - is that PHP?
    Last edited by BlackReef; 08-27-2014 at 09:44 AM.

  • #6
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,389
    Thanks
    13
    Thanked 353 Times in 349 Posts
    Quote Originally Posted by BlackReef View Post
    DOM - is that PHP?
    nope, DOM is an independent interface to interact with certain object (like HTML/XML documents).

    both PHP and JavaScript have a DOM implementation, but usually by DOM is meant the JavaScript implementation since that is how your JS interacts with the browser.

    btw. unless your page is exclusively built through JS, you can circumvent almost every JS security by either disabling JS or checking the source code.
    … or simply by providing false information.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer

  • #7
    Regular Coder
    Join Date
    Apr 2010
    Posts
    220
    Thanks
    116
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Dormilich View Post
    nope, DOM is an independent interface to interact with certain object (like HTML/XML documents).

    both PHP and JavaScript have a DOM implementation, but usually by DOM is meant the JavaScript implementation since that is how your JS interacts with the browser.

    btw. unless your page is exclusively built through JS, you can circumvent almost every JS security by either disabling JS or checking the source code.
    … or simply by providing false information.
    Yea but as with most sites that require age verification, its more of just a formality. I just want to make sure that nomatter what URL they go to they still get the age popup, and then utilize cookies so if they are a return visitor they are not asked again.

  • #8
    Senior Coder Dormilich's Avatar
    Join Date
    Jan 2010
    Location
    Behind the Wall
    Posts
    3,389
    Thanks
    13
    Thanked 353 Times in 349 Posts
    then simply call a function on load, check for the cookie else display a modal dialog.
    The computer is always right. The computer is always right. The computer is always right. Take it from someone who has programmed for over ten years: not once has the computational mechanism of the machine malfunctioned.
    André Behrens, NY Times Software Developer


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •