Disable button whenever a text field is empty dynamically

前端 未结 5 1023
不知归路
不知归路 2020-12-03 21:43

Here\'s my code:

 0) document.getElementById(\'start_button\').disabled = false; else document.get         


        
5条回答
  •  孤街浪徒
    2020-12-03 22:12

    Easiest way to do it :-

    Simple Html and JavaScript : Run the snippet (Just 7 lines)

    function success() {
    	 if(document.getElementById("textsend").value==="") { 
                document.getElementById('button').disabled = true; 
            } else { 
                document.getElementById('button').disabled = false;
            }
        }
    
    

    I have used textarea, but you can use any html input tags and try it out! Happy coding!

提交回复
热议问题