var myDayStr = document.CheckDate.formDate.value;
var myMonthStr = document.CheckDate.formMonth.value;
var myYearStr = document.CheckDate.formYear.value;
var myMonth = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'); var myDateStr = myDayStr + ' ' + myMonth[myMonthStr] + ' ' + myYearStr;
/* Using form values, create a new date object
using the setFullYear function */
var myDate = new Date();
myDate.setFullYear( myYearStr, myMonthStr, myDayStr );
if ( myDate.getMonth() != myMonthStr ) {
alert( 'I\'m sorry, but "' + myDateStr + '" is NOT a valid date.' );
} else {
alert( 'Congratulations! "' + myDateStr + '" IS a valid date.' );
}
}
Back to JavaScript Tutorial Page | Back to JavaScript Validations Page |
No comments:
Post a Comment