Reputation: 405
I am using a textbox on my page which is used to enter year in yyyy-yyyy
format.
Can you tell how can i validate textbox in this format through javascript??
Thanks in advance...
Upvotes: 1
Views: 1870
Reputation: 1990
If you are not using any javascript library (like jQuery, etc), Javascript Regular Expressions could be used for validating the input.
Upvotes: 2
Reputation: 2300
You can match it with a regular expression:
var pattern = /\d{4}-\d{4}/;
Upvotes: 4