Monday, June 2, 2008

javascript:DOB Check

var month=document.getElementById(FinalControlID6).value;
var day=document.getElementById(FinalControlID7).value;
var year=document.getElementById(FinalControlID8).value;
if((month == "02" )&& (day == "30" || day == "31"))
{
alert("You have selected an invalid DOB");
document.getElementById(FinalControlID7).focus();
return false;
}

if((month == "04" || month=="06" || month=="09" || month=="11") && (day == "31"))
{
alert("You have selected an invalid DOB");
document.getElementById(FinalControlID7).focus();
return false;
}

if(!(year%400 ==0 || (year%100 != 0 && year%4 == 0)))
{
if(document.getElementById(FinalControlID7).value.trim() == "29" && document.getElementById(FinalControlID6).value.trim() == "2")
{
alert("You have selected an invalid DOB");
document.getElementById(FinalControlID7).focus();
return false;
}

}

No comments: