RegExp test for date in DD.MM.YYYY format


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.