Answer the question
In order to leave comments, you need to log in
How to change client validation behavior in ASP.NET Web.Forms?
You need to change the behavior of client-side validation - namely, add the class "error" to the parent element of the field and to the container of these fields.
Project on asp.net webforms (framework version 4.5) Added the Microsoft.AspNet.ScriptManager.WebForms.5.0.0
package to the project Added the
line to the ScriptManager
<asp:ScriptReference Name="WebForms.js" Assembly="System.Web" Path="~/Scripts/WebForms/WebForms.js" />
$(function(){
if (typeof ValidatorUpdateDisplay != 'undefined') {
var originalValidatorUpdateDisplay = ValidatorUpdateDisplay;
ValidatorUpdateDisplay = function (val) {
if (!val.isvalid) {
$("#" + val.controltovalidate).css("border", "2px solid red");
}
originalValidatorUpdateDisplay(val);
}
}
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question