
//****************************charactercheck eND HERE **********************************
function getAge() {
month = ((document.getElementById('sMonth').value)-1);
date = document.getElementById('sDay').value;
year = document.getElementById('sYear').value;
 
	if(document.getElementById('sMonth').value == "0")
	{
		return false;
	}
	if(document.getElementById('sYear').value == "0")
	{
		return false;
	}
 //if (month != parseInt(month)) { alert('Type Month of birth in digits only!'); return false; }
// if (date != parseInt(date)) { alert('Type Date of birth in digits only!'); return false; }
 //if (year != parseInt(year)) { alert('Type Year of birth in digits only!'); return false; }
 if (year.length < 4) { alert('Type Year of birth in full!'); return false; }

 today = new Date();
 dateStr = today.getDate();
 monthStr = today.getMonth();
 yearStr = today.getFullYear();

 theYear = yearStr - year;
 theMonth = monthStr - month;
 theDate = dateStr - date;

 var days = "";
 if (monthStr == 0 || monthStr == 2 || monthStr == 4 || monthStr == 6 || monthStr == 7 || monthStr == 9 || monthStr == 11) days = 31;
 if (monthStr == 3 || monthStr == 5 || monthStr == 8 || monthStr == 10) days = 30;
 if (monthStr == 1) days = 28;

 document.getElementById('sAge').value = theYear;

 if (month < monthStr && date > dateStr) { document.getElementById('sAge').value = parseInt(document.getElementById('sAge').value) + 1;
                                           document.getElementById('dMonth').value = theMonth - 1; }
 if (month < monthStr && date <= dateStr) { document.getElementById('dMonth').value = theMonth; }
 else if (month == monthStr && (date < dateStr || date == dateStr)) { document.getElementById('dMonth').value = 0; }
 else if (month == monthStr && date > dateStr) { document.getElementById('dMonth').value = 11; }
 else if (month > monthStr && date <= dateStr) { document.getElementById('sAge').value = document.getElementById('sAge').value - 1;
                                                 document.getElementById('dMonth').value = ((12 - -(theMonth)) + 1); }
 else if (month > monthStr && date > dateStr) { document.getElementById('dMonth').value = ((12 - -(theMonth))); }

 if (date < dateStr) { document.getElementById('dDate').value = theDate; }
 else if (date == dateStr) { document.getElementById('dDate').value = 0; }
 else { document.getElementById('sAge').value = document.getElementById('sAge').value - 1; document.getElementById('dDate').value = days - (-(theDate)); }


}
//Age Calculation Ends here

