Is there an isDate function in jQuery?
It should return true if the input is a date, and false otherwise.
I arrived at this solution, made more complicated as I use the European format and javascript is clearly american!
function CheckDate()
{
var D = document.getElementById('FlightDate').value;
var values = D.split("-")
var newD = values [1] + "/" + values [0] + "/" + values[2]
var d = new Date(newD);
if(d == 'Invalid Date')document.getElementById('FlightDate').value = "";
}
Messy, but does the job. If your users are american and put the day in the middle, (which I'll never understand!), then you can leave out the split and creation of the newD.
It is probable that I can override the default americanism in the JS by setting culture or some such, but my target audience is exclusively European so it was easier to rig it this way. (Oh, this worked in Chrome, haven't tested it on anything else.)