[英]how can i validate year textbox in javascript?
I am using a textbox on my page which is used to enter year in yyyy-yyyy
format.我在我的页面上使用了一个文本框,用于以
yyyy-yyyy
格式输入年份。
Can you tell how can i validate textbox in this format through javascript??你能告诉我如何通过 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.如果您没有使用任何 javascript 库(如 jQuery 等),则可以使用Javascript 正则表达式来验证输入。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.