regex - RegExp date validation in javascript -


i learned regular expressions , created dd-mm-yyyy date validator regular expressions:

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

regular expression visualization

debuggex demo

it seems work fine. wondering if there improvements made make sure there no errors. suggestions?

why reinvent wheel. take of built-in date parsing method date.parse(string) this:

var timestamp = date.parse(str); // str input string data var date = null if (isnan(timestamp) == false)     date = new date(timestamp); else     alert("invalid date"); 

Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

java.util.scanner - How to read and add only numbers to array from a text file -