How to display jQuery Validation error container only on submit

后端 未结 6 920
南笙
南笙 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:38

    I would remove the errorContainer and then intercept the validation on postback and in there add a container-error manually like this:

    $("#frmEnregistrer").bind("invalid-form.validate", function(e, validator) {
      var err = validator.numberOfInvalids();
      if (err) {
        container.html("THERE ARE "+ err + " ERRORS IN THE FORM")
        container.show();
      } else {
        container.hide();
      }
    }).validate({ ... })
    

提交回复
热议问题