1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

following jquery code not working when deployed on servers

Discussion in 'jQuery' started by sana kana, Feb 5, 2020.

  1. #1
    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;
    error.data("unobtrusiveContainer", container);
    if (replace) {
    else {
    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) {
    $.each(validator.errorList, function () {
    $("").html(this.message.replace('|', '')).appendTo(list);
    Code (markup):
    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

    <add key="webpages:Version" value="" />
    <add key="webpages:Enabled" value="false" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    Last edited by a moderator: Feb 5, 2020
    sana kana, Feb 5, 2020 IP