Disable/Enable Submit Button until all forms have been filled

后端 未结 9 608
囚心锁ツ
囚心锁ツ 2020-12-13 06:59

I want my form submit button to be disabled/enabled depending on if the form is completely filled.

When the inputs are filled, the disabled button changes to enabled

9条回答
  •  情歌与酒
    2020-12-13 07:47

    I just posted this on Disable Submit button until Input fields filled in. Works for me.

    Use the form onsubmit. Nice and clean. You don't have to worry about the change and keypress events firing. Don't have to worry about keyup and focus issues.

    http://www.w3schools.com/jsref/event_form_onsubmit.asp

    ...
    function validateCreditCardForm(){ var result = false; if (($('#billing-cc-exp').val().length > 0) && ($('#billing-cvv').val().length > 0) && ($('#billing-cc-number').val().length > 0)) { result = true; } return result; }

提交回复
热议问题