Question

Now i modify onerror and onsucces methods in jquery.valiadte.unobtrusive.js like this:

 function onSuccess(error) {  // 'this' is the form element
    var container = error.data("unobtrusiveContainer"),
        replace = $.parseJSON(container.attr("data-valmsg-replace"));

    if (container) {
        container.addClass("field-validation-valid").removeClass("field-validation-error");
        error.removeData("unobtrusiveContainer");
        var parent = container.parent();
        parent.css("display", "block");
        parent.addClass("validLabel").removeClass("invalidLabel");
        parent.children().css("display", "none");
        var label = parent.parent().children("label:first-child,.label:first-child");
        label.removeClass("errorLabel");
        var info = parent.parent().children(".infoLabel");
        info.css("display", "none");
        $("#aCGVValidate").removeClass("validLabel");
        if (replace) {
            container.empty();
        }
    }
}

and on error:

 function onError(error, inputElement) {  // 'this' is the form element
    var container = $(this).find("[data-valmsg-for='" + inputElement[0].name + "']"),
        replace = $.parseJSON(container.attr("data-valmsg-replace")) !== false;

    container.removeClass("field-validation-valid").addClass("field-validation-error");
    error.data("unobtrusiveContainer", container);
    var parent = container.parent();
    parent.css("display", "block");
    parent.addClass("invalidLabel").removeClass("validLabel");
    parent.children().css("display", "inline-block");
    error.data("unobtrusiveContainer", container);
    var label = parent.parent().children("label:first-child,.label:first-child");
    label.addClass("errorLabel");
    var info = parent.parent().children(".infoLabel");
    info.css("display", "none");
    if (replace) {
        container.empty();
        error.removeClass("input-validation-error").appendTo(container);
    }
    else {
        error.hide();
    }
}

I need to do the modification outside of the library to change style, how can override this methods outside of the lib?? (My objetif is to have css like this:)enter image description here

Was it helpful?

Solution

i use highlight, unhighlight callback functions

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top