Pages

Wednesday, July 14, 2010

Regular Expression for Date

Regular Expression for date format MM/dd/yyyy

^([1-9]|0[1-9]|1[012])[/]([1-9]|0[1-9]|[12][0-9]|3[01])[/](19|20)\\d\\d$

2 comments:

  1. nice... thanks for sharing.. can u plz elaborate how to change this expression if we have globalized the date format.. is there any way to do it in regular expression so that it changes dynamically?

    ReplyDelete
  2. If you use regular expression validator then regular expression is hard code identity but you can change it in Code behind file using validate expression property. Just like different languages have different date validate expression then on the language base you can change regular expression property

    ReplyDelete