File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes HTML, CSS and JavaScript and the fly likes use regular expression to check date format in javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "use regular expression to check date format in javascript" Watch "use regular expression to check date format in javascript" New topic
Author

use regular expression to check date format in javascript

kay lin
Ranch Hand

Joined: May 20, 2004
Posts: 132
hi:
i have some code that uses regular expression to check a Date's format in javascript. The format i want is
yyyy-MM-dd HH:mm

so, the regular expression I used in my javascript is
[code]
/^(\d{2}|\d{4})(\/|-|\.)(\d{1,2})\2(\d{2}|\d{4})\s\d{2}\W\d(2)/
[code]

I am not very familar with regular expression. So If i want force the ":" to follow the 2 digits representing HH, what syntax should i use?
\D( or \W(? please let me know.

thanks
 
 
subject: use regular expression to check date format in javascript