Date validation in javascript

The method below will valdiate a date.
This will not take care for 29 Feb or 30 Feb or 31 Feb
It is a basic date valdiation.


function checkDate(input) {
var validformat = /^(0[1-9]1[012])[-](0[1-9][12][0-9]3[01])[-](1920)\d\d+$/;
var returnval = true;
if (!validformat.test(input)) {
alert("The specified delivery date is invalid. Please specify the date in the proper format(MM-DD-YYYY) to continue.");
returnval = false;
}
return returnval;
}

If you have better solution, just tell me !

0 comments: