var minAge = 6;
var maxAge = 16;
function _calcAge() {
var date = new Date(document.getElementById("DOB").value);
var today = new Date();
var timeDiff = Math.abs(today.getTime() - date.getTime());
var age1 = Math.ceil(timeDiff / (1000 * 3600 * 24)) / 365;
document.getElementById('candAge').value = parseInt(age1);
return age1;
}
//Compares calculated age with minimum age and acts according to rules//
function setAge() {
var age = _calcAge();
//alert("my age is " + age);
if (age < minAge) {
window.alert("You are not allowed to apply for admission in school, minimum age is 6");
} else if (age > maxAge) {
window.alert("You are not allowed to apply for admission in school, maximum age is 16");
} else {
var std = parseInt(age) - 5;
window.alert("The suitable class to your age is " + std);
// window.open(main.htm, _self);
}
}