title: How to disable button when text box is clear?
body: <p>I need to enable textbox when user start to print on it end disable button when text box is empty.</p>
  
  <p>here is my text box and button:</p>
  
  <pre><code>   &lt;button id="btnSaveLayer" class="ui-btn ui-icon-plus ui-btn-icon-left ui-btn-b" onclick="SaveNewLayer()" disabled&gt;save&lt;/button&gt;
     &lt;input type="text" id="newLayerName" placeholder="name" value="" /&gt; 
  </code></pre>
  
  <p>Here is the code that I use:</p>
  
  <pre><code>function setElementsDisabled() {
      $('#newLayerName').keyup(function () {
          if ($(this).val().length != 0)
              $('#btnSaveLayer').attr('disabled', false);
          else
              $('#btnSaveLayer').attr('disabled', true);
      })
  }
  </code></pre>
  
  <p>From function above you can see that, when user start to enter text in text box butten enabled and when the user remove from text box button disabled.</p>
  
  <p>And it works perfect!!!</p>
  
  <p>But when I clear button programmatically using this jquery code:</p>
  
  <pre><code>  $("#newLayerName").val('');
  </code></pre>
  
  <p>The text from textbox is removed but, button is not disabled.</p>
  
  <p>Any idea how to change my function <code>setElementsDisabled</code> so that when text box is empty the button is disabled?</p>