0

Is it possible to send the Validate error message to other function? As an example, I have a notification function that displays a determined message and fades away after (n) seconds:

notify("My error message", { selector: '#form-notification' });

How to use that notify function with this:

$("#myForm").validate({
    submitHandler: function(form) {
        var options = { 
            target: '#save_form',                               
            dataType: 'json',
            beforeSubmit: showRequest,
            success: showResponse 
        }; 
        $(form).ajaxSubmit(options); 
    }
});     

Thanks in advance.

1

1 Answer 1

2

You can use the showErrors callback to customize what happens when an error occurs. Include defaultShowErrors() to keep the default action.

$("#myForm").validate({
   showErrors: function(errorMap, errorList) {
        //custom code here

        this.defaultShowErrors();
    }
 });

http://docs.jquery.com/Plugins/Validation/validate

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.