I want to prevent users from entering url’s (like a href=””) in a TextBox.
I want to use a regular expression validator but no idea what to write?
How can I do it?
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.
Do you mean you literally want to prevent them from entering the text
href="in the TextBox, or you want to prevent URLs?Either way, a RegexValidator is one solution:Actually, as far as I know there is not a very easy way to use an OOTB-regex validator to do a negative contains (i.e. “fail if any match”). Someone smarter may be able to correct me on that. But you can definitely use a custom validator:
Codebehind: