Is there anyway to use DataAnnotations in MVC 3 to not allow HTML is used in a textbox?
I see a way to allow using HTML (AllowHTMLAttribute) but what if i dont want the user to type any HTML in the textbox and want to warning him?
Thanks 🙂
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.
You have to write a custom RegularExpressionAttribute … something like this:
You must register the adapter to enable client side validation, so in Application_Start in Global.asax add this line of code:
And in your model, add the attribute to the properties you want to disallow html tags, like this: