开发者

Javascript validation for DD/MM/YY

I need to check for this in javascript. So开发者_Go百科 i need to pass in something like this

var validdate = ^([0]?[1-9]|[1|2][0-9]|[3][0|1])[./-]([0]?[1-9]|[1][0-2])[./-]([0-9]{4}|[0-9]{2})$;

This is throwing a "expected expression" error in VS. Whats wrong with that expression? Thanks for helping guys!


You're getting an error, because in JS a RegExp literal starts and ends with a slash (/)

var validdate = /^([0]?[1-9]|[1|2][0-9]|[3][0|1])[.\/-]([0]?[1-9]|[1][0-2])[.\/-]([0-9]{4}|[0-9]{2})$/;
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜