Trigger standard HTML5 validation (form) without using submit button?

前端 未结 12 1421
攒了一身酷
攒了一身酷 2020-11-28 07:07

Anyone who know how I can trigger the standard HTML5 validation in a form without using a submit button? (JavaScript or jQuery).

I do not want to se

12条回答
  •  半阙折子戏
    2020-11-28 07:43

    I think its simpler:

    $('submit').click(function(e){
    if (e.isValid())
       e.preventDefault();
    //your code.
    }
    

    this will stop the submit until form is valid.

提交回复
热议问题