JavaScript Validate Date Example

How to use JavaScript to validate dates

JavaScript Validate Date ExampleSo often I have a form on the page that includes a date field and I want to validate that date without a round trip to the server. Here is a simple JavaScript function that will do just that.

The function accepts the date value and a string indicating the format expected (i.e. ‘MDY’). Simply call this function from the form either onChange of the field or on submit of the form. I prefer the on submit approach and check all the fields at once. I find it less annoying that bugging the user on every field change.
Continue reading “JavaScript Validate Date Example”