javascript regular expressions can accomplish this for you
http://www.w3schools.com/jsref/jsref_obj_regexp.aspSimply test your pattern vs the input, if a match is found than it's valid otherwise it's invalid.
There are several examples of validating date formats in google.
/^(\d{4})[./-](\d{1,2})[./-](\d{1,2})$/
For one
which should accept yyyy.mm.dd or yyyy-mm-dd or yyyy/mm/dd
How it reads is:
Beginning of line must be digits of 4 characters, + (. or / or -) + digits of 1 or 2 + (. or / or -) + digits of 1 or 2
In my personal opinion, I wouldn't use regex to validate a specific format of date, but rather convert the inputed date to the desired format.
Uniforming if you will.
You can use mootools.more.date to accomplish this
http://mootools.net/docs/more/Native/Date#Date:parseand
http://mootools.net/docs/more/Native/Date#Date:formatFirst to parse the inputed data to a valid date, then format to format it to your desired format.
You can use the DOM to show the results to the user.
Then you can use
http://mootools.net/docs/more/Native/Da ... e:timeDiffTo verify that Time A is less than Time B
Alternatively you can look up javascript functions for datediff, but won't be as flexible as MooTools.
Do you have a fall back in-case your users disabled javascript?
EG: HA form validation, (disable javascript), Submit form by-passing validation, and potentially crashing form processor, exposing database