If input field is empty, disable submit button

后端 未结 5 1976
不知归路
不知归路 2020-12-04 19:59

I\'m trying to disable submit button if the user hasn\'t provided any text.

At first sight it looks that everything works just fine, but if user types some text, th

5条回答
  •  忘掉有多难
    2020-12-04 20:40

    An easy way to do:

    function toggleButton(ref,bttnID){
        document.getElementById(bttnID).disabled= ((ref.value !== ref.defaultValue) ? false : true);
    }
    
    
    
    
    

提交回复
热议问题