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

前端 未结 12 1435
攒了一身酷
攒了一身酷 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:44

    form.submit() doesn't work cause the HTML5 validation is performed before the form submition. When you click on a submit button, the HTML5 validation is trigerred and then the form is submited if validation was successfull.

提交回复
热议问题