sana kana

sana kana

  • NA
  • 15
  • 424

following jquery code not working when deployed on servers

Feb 5 2020 2:01 PM
There are different sections on the page(ASP.net MVC) with same controls(ex:phone,email). I want the following validation message to be displayed differently in Validation Summary(with section name) and beside individual text boxes(w/o section name)
This is the validation message specified in the model
[Required(ErrorMessage = "Chief Executive - |Name is required")]
[Required(ErrorMessage = "Medical Director - |Name is required")]
The code to replace the '|' symbol in jquery.validate.unobtrusive.js is
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function onError(error, inputElement) { // 'this' is the form element
var container = $(this).find(".name) +
"']"),
replaceAttrValue = container.attr("data-valmsg-replace"),
replace = replaceAttrValue ? $.parseJSON(replaceAttrValue) !== false : null;
container.removeClass("field-validation-valid").addClass("field-validation-error");
error.data("unobtrusiveContainer", container);
if (replace) {
container.empty();
error.removeClass("input-validation-error").appendTo(container);
}
else {
error.hide();
}
error.text(error.text().substr(error.text().indexOf("|") + 1));
}
function onErrors(event, validator) { // 'this' is the form element
var container = $(this).find(""),
list = container.find("ul");
if (list && list.length && validator.errorList.length) {
list.empty();
container.addClass("validation-summary-errors").removeClass("validation-summary-valid");
$.each(validator.errorList, function () {
$("").html(this.message.replace('|', '')).appendTo(list);
});
}
}
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
The pipe symbol is replaced with space and displayed as desired in local host. But when the code is deployed to servers, I am getting the same validation message(with section names) displayed in both validation summary and beside the text boxes also.
I am ready to provide other code also.
I also have this in web.config
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="false" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>

Answers (3)