• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

regular expression to check date

pushVTEC

Senior member
Would this regular expression work to make sure that the input is in MM\DD\YYYY form?

/[0-9]{2}\[0-9]{2}\[0-9]{4}/
 
You need to escape the backslashes. Other than that, yes. Of course, dates like 15/37/9876 will still match just fine, and you may want to allow things like 1/3/2004, your regex requires 01/03/2004.
 
your expression doesn't limit the months to be <= 12. at the very minimum, you might say that the first digit is either a 0, 1, or missing.

edit: <= 12 instead of < 12
 
why isn't this working i want it to check YYYY\MM\DD
var regex = /(19|20)\d\d[\](0[1-9]|1[012])[\](0[1-9]|[12][0-9]|3[01])/;

i get a unmatched ) in regular expression
 
Back
Top