How to allow user to enter only 0 or 1 in the textbox.I am using C#.net. Textbox has maxlength is 1.I am want to add validation expression in regular expression.I don’t want use javascript.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I understand the question in the following way:
you don’t want to use javascript only to prevent that the users enters something else than 0 or 1 but a validator which can be used on client- and on serverside.
I would use a
RangeValidatorwithType="Integer"and appropriateMinimumValueandMaximumValueinstead.Note: If the input control is empty, no validation functions are called and validation succeeds. Use a
RequiredFieldValidatorcontrol to prevent the user from skipping an input control.As other have mentioned, a
CheckBoxmight be more appropriate for this task.