Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 766111
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T16:59:32+00:00 2026-05-14T16:59:32+00:00

I am using the scripts from here http://www.quirksmode.org/js/cookies.html and have successfully created a cookie..

  • 0

I am using the scripts from here http://www.quirksmode.org/js/cookies.html and have successfully created a cookie.. it is set based on the users response to the age drop down. However I am having trouble doing anything with it. I would like to have a style defined if a cookie is present. Here is the bulk of my scripts..

function createCookie(name,value,days){
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    }
    else var expires = "";
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function checkAge(){
    var min_age = 13;
    var year = parseInt(document.forms["emailForm"]["year"].value);
    var month = parseInt(document.forms["emailForm"]["month"].value) - 1;
    var day = parseInt(document.forms["emailForm"]["day"].value);
    var theirDate = new Date((year + min_age), month, day);
    var today = new Date;

    if ( (today.getTime() - theirDate.getTime()) < 0) {
        var el = document.getElementById('emailBox');
        if(el){
            el.className += el.className ? ' youngOne' : 'youngOne';
        }
        document.getElementById('emailBox').innerHTML = "<style type=\"text/css\">.formError {display:none}</style><p>Good Bye</p><p>You must be 13 years of age to sign up.</p>"; 
        createCookie('age','not13',0)
        return false;
    }
    else {
        createCookie('age','over13',0)
        return true;
    };
};

window.onload=function(){
   var x = readCookie('not13');
   if (x)  {    
        document.getElementById('emailBox').innerHTML = "<style type=\"text/css\">.formError {display:none}</style><p>Good Bye</p><p>You must be 13 years of age to sign up.</p>"; 
   }
}

Age verification works and cookie is set…. no errors (from Firebug).. can anyone see what I am doing wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T16:59:32+00:00Added an answer on May 14, 2026 at 4:59 pm

    I got it.. I was looking for the cookie value and needed to look for the name and then create an if statement based on the value. so..

     var x = readCookie('age');
    if (x=='not13')  {    
       document.getElementById('emailBox').innerHTML = "<style type=\"text/css\">.formError {display:none}</style><p>Good Bye</p><p>You must be 13 years of age to sign up.</p>"; 
       }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using the following html to load dojo from Google's hosting. <script src=http://www.google.com/jsapi></script> <script
I have a script that checks responses from HTTP servers using the PEAR HTTP
I'm able to run Groovy scripts from Groovy using proc = cmd /c groovy
I am using HTML, and I'd like to hide the script tag from the
First is there any technique for using Action Script for recording sound from microphone?
The .NET Security Policy can be changed from a script by using CasPol.exe .
All I wish to call the svnlook commandline from my MSbuild script using the
You launch a java program from a console (maybe using a .bat script). I
I'm trying to run Python scripts using Xcode's User Scripts menu. The issue I'm
I've started using Vim to develop Perl scripts and am starting to find it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.