JQuery validation messages only show up after multiple submits

前端 未结 2 1381
余生分开走
余生分开走 2020-12-21 13:49

I am trying to validate a form with the jquery-validate plugin. The html page doesn\'t show the error messages from the validation until I click submit twice. I know the s

2条回答
  •  甜味超标
    2020-12-21 14:24

    I wouldn't advise using submit() as a means of activating form validation. Instead, use your submit button:

    $('input[type=submit]').click(function(event) {
       // Do your validation, if it fails use event.preventDefault(); 
    });
    

提交回复
热议问题