How to display jQuery Validation error container only on submit

后端 未结 6 943
南笙
南笙 2021-02-07 10:14

I am trying to make the Validation plugin work. It works fine for individual fields, but when I try to include the demo code for the error container that contains all of the err

6条回答
  •  忘掉有多难
    2021-02-07 10:51

    I don't know if the validation plugin provides an option for this, but you can probably use standard jQuery to achieve what you want. Make sure you're container is initially hidden, by setting the display style to none:

    
    

    Then you can hookup an onsubmit event to the form which will make the container visible as soon as an attempt is made to submit the form:

    jQuery('#formId').onsubmit(function() {
        // This will be called before the form is submitted
        jQuery('#container').show();
    });
    

    Hopefully combining that with your existing code should do the trick.

提交回复
热议问题