jquery validate - validating a field on pageload

前端 未结 2 733
小鲜肉
小鲜肉 2021-01-26 11:51

I\'ve got an input field on my plain html form that I would like to be marked as invalid (and the error message shown) from the moment the page loads.

Is this possible t

2条回答
  •  长情又很酷
    2021-01-26 11:55

    I think you would have to have the form you are validating be submit on the page load. Probably something like this:

       $(document).ready(function() {
           $('form').validate(/* set all of your validator options here */);
           $('form').trigger('submit');
        });
    

提交回复
热议问题