开发者

how can i validate year textbox in javascript?

开发者 https://www.devze.com 2023-03-10 16:12 出处:网络
I am using a textbox on my page which is used to e开发者_StackOverflow中文版nter year in yyyy-yyyy format.

I am using a textbox on my page which is used to e开发者_StackOverflow中文版nter year in yyyy-yyyy format.

Can you tell how can i validate textbox in this format through javascript??

Thanks in advance...


You can match it with a regular expression:

var pattern = /\d{4}-\d{4}/;


If you are not using any javascript library (like jQuery, etc), Javascript Regular Expressions could be used for validating the input.

0

精彩评论

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