(annoying for the user) The interesting problem is whether they put in a valid date and I would suggest exploiting how flexible js is: Rather than throwing the generic "Invalid date format" error which does not make much sense to the user.
I modify the rest of the code to provide valid error message like month cannot be more than 12, days cannot be more than 31 etc., The problem with using Regular expression is it is difficult to identify exactly what went wrong.
This routine DOES NOT check that the date or time input values are valid, just that they match the required format (d/m/y and h:m). Once you're in control of the input format, it's a lot easier to check that the values are actually valid.
Server side validation is performed by a web server, after input has been sent to the server.
Client side validation is performed by a web browser, before input is sent to a web server.
Now we will see how we can validate our entered form data before submitting it to the web server.
The following example shows how to validate an entered email address.
If not, the input is compared to the regular expression.