
hi
i am entering date, month and year in corresponding three drop down list. how to validate the date.....?

// validate that the user made a selection other than default
function isChosen(select)
{
if (select.selectedIndex == 0)
{
alert("Please make a choice from the list."); return false;
}
else
{
return true;
} }
function daysInFebruary (year){ // February has 29 days in any year evenly divisible by four, // EXCEPT for centurial years which are not also divisible by 400. return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 ); }
function DaysArray(n) {
for (var i = 1; i <= n; i++) {
this[i] = 31
if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
if (i==2) {this[i] = 29}
}
return this
}
function focusElement(formName, elemName) {
var elem = document.forms[formName].elements[elemName]; elem.focus();
elem.select();
}
function valid(dob1,dob2,dob3) { var daysInMonth = DaysArray(12) var date=dob1.value var month=dob2.value var year=dob3.value if((month==2 && date>daysInFebruary(year)) || date>daysInMonth[month]) { alert("Please enter a valid day") return false } return true }
function validateForm(form) {
if (isChosen(form.dob1)) {
if (isChosen(form.dob2)) {
if (isChosen(form.dob3)) {
if(valid(form.dob1,form.dob2,form.dob3)){ document.frm.action="<%=contextPath%>/Conformation";
//"conformation" is for servelet mapping
document.frm.submit();
} } } }
return false;
}