开发者

Regular expression to validate that the entered date is not before 1 jan 2000

I need a regular expression to check that the given date is not before 1 jan 2000, If the user enters the date before 1 jan 2000 it gives error otherwise no work. I am using a text box for user input with the ajax date time piker.

I want to check it on client side not server 开发者_如何学编程side. Any code, suggestion or help is appreciated.


If you are on server side code, why don't you check use something like this:

if (dtPicker.Date != null) {
    if ( dtPicker.Date.Year < 2000 ) {
        isValid = false;
    }
}

Is there any reason to test with an regular expression?

In general, a regular expression will have problems when you change the localizatino, eg the user enters the date using German or Italian or some other localization.


Try /(\d{1,2}\.){2}2\d{3}/

First two months (not checked for validity), then a year starting with 2.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜