Posted By

indamix on 04/01/09


Tagged

javascript regexp


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

indamix
hbogs


RegExp test for date in DD.MM.YYYY format


 / Published in: JavaScript
 

  1. (0[1-9]|[12][0-9]|3[01])\.(0[1-9]|1[012])\.(19|20)\d\d
  2.  
  3. /*
  4.  
  5. 21.04.2009 true
  6. 21.04.1909 true
  7. 21.04.09 false
  8. 21-04-2009 false
  9. 22.32.2009 false
  10. 22.21.2109 false
  11.  
  12. To pass dates like 21-04-2009 and 21 04 2009 use:
  13. (0[1-9]|[12][0-9]|3[01])[ \.-](0[1-9]|1[012])[ \.-](19|20)\d\d
  14.  
  15. To pass dates like 21.04.09 and 21-04-09 use:
  16. (0[1-9]|[12][0-9]|3[01])[ \.-](0[1-9]|1[012])[ \.-](19|20|)\d\d
  17.  
  18. */

Report this snippet  

You need to login to post a comment.