Aneeq Tariq
Aneeq Tariq

Reputation: 436

jquery validation plugin won't show error again

i am using jquery validation plugin for form validation. The problem is this, that when i use errorPlacement and success opption in validate, my error doesn't appear again after once validate, if i comment errorPlacement and success and run the script again it work fine.

$('#registrationForm').validate({
    rules : {},
    messages : {},
    errorPlacement: function(error, element) {
    var container = $('<div />');
    container.addClass('Ntooltip');  // add a class to the wrapper
    error.insertAfter(element);
    error.wrap(container);
    $("<div class='errorImage'></div>").insertAfter(error);
    },

    success: function(element) {
        $(element).addClass("checked");
    }
});

But if i use errorPlacement and success in my validation script, then submit my form it work fine at once, all error were show up, after that if i insert valid input then my error hide and showed this is a valid input. Problem: after insert valid input i again change my valid input to invalid it doesnot show error again

Upvotes: 0

Views: 1056

Answers (2)

Aneeq Tariq
Aneeq Tariq

Reputation: 436

i found my answer this article jquery validation errorPlacement issue when adding tooltip style error message , I didn't find that time so i post my Question.

showErrors: function (errorMap, errorList) {
            for (var i = 0; errorList[i]; i++) {
                var element = this.errorList[i].element;
                this.errorsFor(element).remove();
            }
            this.defaultShowErrors();
        }

Upvotes: 2

bastos.sergio
bastos.sergio

Reputation: 6764

Try setting up debug mode to see what's happening internally...

$('#registrationForm').validate({
    debug: true,
    rules : {},
    messages : {},
    errorPlacement: function(error, element) {
    var container = $('<div />');
    container.addClass('Ntooltip');  // add a class to the wrapper
    error.insertAfter(element);
    error.wrap(container);
    $("<div class='errorImage'></div>").insertAfter(error);
    },

    success: function(element) {
        $(element).addClass("checked");
    }
});

Upvotes: 1

Related Questions