This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: use regular expression to check date format in javascript
 
Similar Threads
Problem with a regex
A query about Patten in Java Regular Expression
using regular expression Problem
question : retailer code must contain only 2 alphabets and 3 numbers i.e AB123
Using Patterns for Date String