title: Disable button unless min-length of textarea is reached - Javascript
body: <p>I have a textarea and a button, I want to disable the button until the textarea has reached the min-length.</p>
  
  <p>I thought about something similar to this code:</p>
  
  <p><a href="http://fiddle.jshell.net/K5Pfj/285/" rel="nofollow noreferrer">JsFiddle</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
  $('input[type="submit"]').attr('disabled', true);
  $('input[type="text"],textarea').on('keyup',function() {
      var textarea_value = $("#texta").val();
   
      if(textarea_value != '') {
          $('input[type="submit"]').attr('disabled' , false);
      }else{
          $('input[type="submit"]').attr('disabled' , true);
      }
  });
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;textarea maxlength="20" minlength="5" rows="4" cols="30" id="texta"&gt;&lt;/textarea&gt;
  &lt;input type="submit" value="next" /&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>I tried changing the <code>.val</code> to <code>.minlength</code> and tested it like this:</p>
  
  <pre><code> if(textarea_value &lt; '5') {    
      $('input[type="submit"]').attr('disabled' , false);
   }else{
       $('input[type="submit"]').attr('disabled' , true);
   }
  </code></pre>
  
  <p>but it did not work.</p>
  
  <p>Anyone has an idea how to check if minlength of textarea is reached ? With pure javascript or jquery ?</p>