Switch to full style
JavaScript code examples
Post a reply

validate age entered as selection box in javascript

Wed Oct 26, 2011 12:12 am

Following code check enter as <select> options as day,month and year.

Code:
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){return false;}
else if(
cmbday==0){return false;}
else if(
cmbyear>=2005){return false;}
else if(
age<'.$age.'){
return 
true;
}
 




Re: validate age entered as selection box in javascript

Sat Jul 21, 2012 12:05 pm

You can use an HTTP request to call an exnisitg API which provides the IP. For example there is the XML API at , but there should be much more simpler APIs to access.

Re: validate age entered as selection box in javascript

Tue Jul 24, 2012 1:15 pm

what are u talking about ?

Post a reply
  Related Posts  to : validate age entered as selection box in javascript
 validate mail in jsp     -  
 validate username     -  
 validate e-mail in php     -  
 validate domain name in php     -  
 validate email address in asp     -  
 validate international phone number value     -  
 selection sort     -  
 C++ Selection Sort     -  
 Help with selection sort for strings?     -  
 fill selection options from list     -  

Topic Tags

JavaScript Validation