How do I use jQuery to disable a form's submit button until every required field has been filled?

前端 未结 6 1626
故里飘歌
故里飘歌 2021-01-01 08:21

I have a form with multiple inputs, select boxes, and a textarea. I would like to have the submit button be disabled until all of the fields that I designate as required are

6条回答
  •  -上瘾入骨i
    2021-01-01 08:52

    I recommend taking a slightly different approach and using jquery's validation http://docs.jquery.com/Plugins/validation. The tactic you are suggesting is prone to security holes. The user could easily using firebug enable that button and then submit the form.

    Using jquery validation is clean and it allows you to show error messages under the required fields if so desired on submit.

提交回复
热议问题