Enable/Disable submit button if checkbox is checked/unchecked?

后端 未结 3 2077
Happy的楠姐
Happy的楠姐 2020-11-27 20:17

How to enable the submit button in my HTML form and disable if checkbox was unchecked?

What is wrong with this code?

EnableSubmit = function(val)
{
          


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-27 20:58

    Change your HTML to this:

    Do you accept Terms of Service agreement?
    
    
         I agree to Terms of Service agreement.
    
    

    Reason it's not working: you're not passing your function anything. Actually, because you've not used parentheses with the function name, you've not called the function at all. Passing it this in the context of the onclick HTML event attribute means you're passing a reference to the element's DOM object, giving you access to its checked property.

提交回复
热议问题