TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
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>
Reply
Answers (
3
)
How to make function give row that have different value with
Add date icon beside date value in data table