title: Disabling submit/post button if inputs empty jquery
body: <p>I have been looking all over but did not find anything that worked for me. I am trying to prevent users from sending incomplete forms. I have disabled "submit" by default, and the intent is to remove the "disable" attribute if all inputs have been provided. For some reason the submit button is still disable. I believe the code below should work, but i guess i might be missing something. </p>
  
  <p>FYI - I am using Jquery datepicker and timepicker to let users select dates and times. </p>
  
  <p>Would anyone be able to help a newbie?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script&gt;
   $(document).ready(function() {
       $('.field input').keyup(function() {
   
           var empty = false;
           $('.field input').each(function() {
               if ($(this).val().length == 0) {
                   empty = true;
               }
           });
   
           if (empty) {
               $('.actions input').attr('disabled', 'disabled');
           } else {
               $('.actions input').removeAttr('disabled');
           }
       });
   });
   
  &lt;/script&gt;
  
  
    &lt;div&gt;
  
   &lt;form class="form" name="frm1"  method="POST"&gt; 
   
       &lt;div class='field'&gt;
         &lt;label for="datepicker"&gt;Day:&lt;/label&gt;
         &lt;input type="text" name="txtDate" id="datepicker"&gt; &lt;/br&gt;
       &lt;/div&gt;
       
       &lt;div class='field'&gt;
         &lt;label for="fromtime"&gt;From:&lt;/label&gt;
         &lt;input type="text" name="txtStartTime" id="fromtime"&gt;&lt;/br&gt;
       &lt;/div&gt;
         
       &lt;div class='field'&gt;
         &lt;label for="totime"&gt;To:&lt;/label&gt;
         &lt;input type="text" name="txtEndTime" id="totime"&gt;&lt;/br&gt;
       &lt;/div&gt;
       
       &lt;div class='droppies'&gt;
            &lt;label for="level"&gt;Level&lt;/label&gt;
        &lt;select name="level" id="level"&gt;
      &lt;option selected value='%'&gt;&lt;/option&gt;
      &lt;option value='Beginner'&gt;Beginner&lt;/option&gt;
      &lt;option value='Intermediate'&gt;Intermediate&lt;/option&gt;
      &lt;option value='Advanced'&gt;Advanced&lt;/option&gt;
      &lt;option value='%'&gt;Any levels&lt;/option&gt;
      
        &lt;/select&gt;
       &lt;/div&gt;
       
       &lt;div class='actions'&gt;
        &lt;input type="submit" name="submit" value="search" disabled="disabled"&gt; 
       &lt;/div&gt;
      &lt;/form&gt;
   
  
    &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>