Possible Duplicate:
Regular Expression to validate short and long date in mm/dd/yyyy format in javascript
I am using a regular expression /^\d{1,2}[\/-]\d{1,2}[\/-]\d{4}$/ for validating MM/DD/YYYY in javascript.
But currently it will validate dates like 13/22/2012 , 10/45/2012.
How can i correct it.
Drop the regular expressions and simply use
split()function.Once you have each part of the date separately, you’ll be able to validate it using simple conditional statements.
Bear in mind that any validation done with JavaScript on the client side should not be trusted! Any user can get in there and manipulate your JavaScript. You should always implement validation on the server side as well. Usually client side validation is more of a user experience thing…