/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Age Verification problem

Hey everyone
I have this code:

[CODE]<script><!–

function checkAgeCheckBox(f){

var dob=new Date();
var date=dob.getDate();
var month=dob.getMonth() + 1;
var year=dob.getFullYear();

var cmbmonth=parseInt(document.getElementById(“cmbmonth”).options[document.getElementById(“cmbmonth”).selectedIndex].value);
var cmbday=parseInt(document.getElementById(“cmbday”).options[document.getElementById(“cmbday”).selectedIndex].value);
var cmbyear=parseInt(document.getElementById(“cmbyear”).options[document.getElementById(“cmbyear”).selectedIndex].value);

age=year-cmbyear;

if(cmbmonth>month){age–;}
else{if(cmbmonth==month && cmbday>=date){age–;}}

if(cmbmonth==0){alert(“You must enter the month you were born in.”);return false;}
else if(cmbday==0){alert(“You must enter the day you were born on.”);return false;}
else if(cmbyear==2007){alert(“You must enter the year you were born in.”);return false;}
else if(age<18){alert(“You are Under 18 years of age and are prohibited from entering this site!”);location.replace(“http://www.google.co.uk/”);return false;}
else if(!document.getElementById(“agree”).checked){alert(‘Check the agree box to enter this site.’);return false;}
else{return true;}

}

// –></script>[/CODE]

It seems to work perfectly in Internet explorer 6 but does not work in IE7 or Firefox, this is for a university project and I need to have it working in Firefox. I thought that I had maybe disabled the browsers javascript or something but this is not the case as I have tested it on several different computers. Can anyone help or am i better just giving up?

ps. this sounds mad but it was working perfectly in Firefox and IE7 and i just happened to go back to it one day and it has stopped functioning.

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 11.2007 — No error messages? Duplicate IDs?
Copy linkTweet thisAlerts:
@NicolaFauthorMay 11.2007 — nothing is coming up at all. its just when i click on the subit button it takes you straight to the home page even though it should come up with an error saying that you need to fill in your date of birth?
Copy linkTweet thisAlerts:
@FangMay 11.2007 — Return in the onsubmit?&lt;form action="home.cgi" name="checkAge" onsubmit="return checkAgeCheckBox(this)" method="post"&gt;
Copy linkTweet thisAlerts:
@NicolaFauthorMay 11.2007 — hey ya... this works fantastically now. thankyou so much for your help ?
×

Success!

Help @NicolaF spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...