Disable/Enable Submit Button until all forms have been filled

后端 未结 9 619
囚心锁ツ
囚心锁ツ 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:40

    Just use

    document.getElementById('submitbutton').disabled = !cansubmit;
    

    instead of the the if-clause that works only one-way.

    Also, for the users who have JS disabled, I'd suggest to set the initial disabled by JS only. To do so, just move the script behind the

    and call checkform(); once.

提交回复
热议问题