I have one Textbox. I want to restrict that textbox to allow only years[4 digit].
year must be ranges from 1940 to current year
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Shankar MPosted Dec 13, 2013, 2:27 AM
samantaPosted Dec 13, 2013, 2:19 AM
But if year changes from 2013 to 2014 than?
i dont want to change again.
Shankar MPosted Dec 13, 2013, 1:43 AM
Then, you can use the Server Control Range Validator. Here it is.
You can use the ControlToValidate property to set the TextBox that need to be validated,
and by specifying the Min and Max value.
<asp:RangeValidator ID ="RangeValidator1" runat ="server" ControlToValidate ="txtFiche" MinimumValue ="1940" MaximumValue = "2013" ErrorMessage ="Invalid Input">
asp:RangeValidator>Thanks,
Shankar M
samantaPosted Dec 13, 2013, 1:34 AM
But i want to enter only year in that and it must accept year from 1940 to current year
Shankar MPosted Dec 13, 2013, 1:31 AM
You can set the TextBox MaxLength property to 4 which restrict itself to enter 4 characters only.
Thanks,
Shankar