Stop submit button being pressed until enough words are written in text area

后端 未结 6 2245
感动是毒
感动是毒 2021-01-25 17:24

So basically what I want is for the submit button to be disabled until a certain word count has been reached in the text area.

I have had a look around and tried to find

6条回答
  •  离开以前
    2021-01-25 17:52

    Try out below lines of code,

    $(document).ready(function() {
        $(".submit-name").attr("disabled", "true");
        var minLength = 100;
        $("#your-text-area").bind('keyup', function(event) {
            var String = $("#your-text-area").val()
    
               if (String.length >= minLength )  {  
                    $(".submit-name").removeAttr("disabled");
                } else {
                    $(".submit-name").attr("disabled", "true");        
                }
    
    });
    
    
    
    });
    

提交回复
热议问题