Q:

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.
Can you tell how can i validate textbox in this format through javascript??
Thanks in advance...

A:

You can match it with a regular expression:
var pattern = /\d{4}-\d{4}/;

