0

I'm using plugin jQuery validation to handle invalid fields. So, I set defaults validator like this:

$.validator.setDefaults({
    errorElement: 'span',
    errorClass: 'help-block text-danger',
    errorPlacement: function(error, element) {
        error.prepend("<i class='fa fa-warning'></i> ");
        error.appendTo($(element).parent());
    },
    highlight: function(element) {
        $(element).closest('.form-group').addClass('has-error');
    },
    unhighlight: function(element) {
        $(element).closest('.form-group').removeClass('has-error');
    },
    onfocusout: function(element,event){
        $(element).valid();
    }
});

I added the tag (i) with class (fa fa-warning) errorPlacement

PB : The Tag element does not appear in second focus in field. You can see this in this example https://jsfiddle.net/MokhtarSF/btt17gg9/3/

1 Answer 1

0

Problem Solved

I added showErrors function in validator defaults for handle message error content instead of errorPlacement.

I will keep this link as reference.

`https://jsfiddle.net/MokhtarSF/btt17gg9/3/`

Thanks

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.