Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn off input validation for a single field

I've got an ASP.NET 4 site on which I want to allow people to put '<' in their password. However, .NET gets in the way by blocking (what it sees as) an attempt to put HTML in a form field. I know I can turn off input validation entirely, but I only want to turn it off for this one field. Does anyone know an easy way to do that?

like image 724
eliah Avatar asked Sep 27 '10 14:09

eliah


1 Answers

This is now possible with .NET 4.5.

Update your Web.config:

<httpRuntime targetFramework="4.5" requestValidationMode="4.5" />

Then set ValidateRequestMode="Disabled" on your password controls:

<asp:YourControl id="YourControl" runat="server" ValidateRequestMode="Disabled"/>

Note - after updating web.config, you might run into the error WebForms UnobtrusiveValidationMode requires a ScriptResourceMapping for 'jquery'. See ASP.Net 2012 Unobtrusive Validation with jQuery for more info on that.

More info on RequestValidationMode 4.5: requestValidationMode 4.5 vs 2.0

like image 50
kmdsax Avatar answered Nov 14 '22 02:11

kmdsax