Reputation: 11
I am a first-timer here. Not aware of the rules exactly.
My question is this: I have a TextBox and I want this TextBox to accept years only. The format of the text must be like 2012-2013
Any ideas?
Upvotes: 0
Views: 351
Reputation: 1530
Welcome to Stack...
Here is a Regular expression that should work for you
^([0-9]{4})[./-]+([0-9]{4})$ //Results in 2012-2013 or 2012/2013
And as for adding it to your app, here is an article that could help you.
Upvotes: 1
Reputation: 222692
Put this regex in your code
^[12][0-9]{3}$