grey out submit button until form filled out

后端 未结 3 751
萌比男神i
萌比男神i 2021-02-09 02:23

I have the following form:

 
3条回答
  •  渐次进展
    2021-02-09 03:07

    If you are a beginner of javascript, a better option would be

    Add HTML as follows

    
       First name: 
       
    
    

    Now add validateForm() as

    function validateForm() {
       // Validate all fields in the form
       return true; // if all form entries are valid. else return false
    }
    

    Note: This will not grey-out the submit button. But in this case submit will work only if all the entries are valid.

提交回复
热议问题