title: jQuery: Find all the visible required fields
body: <p>I am trying to find all the fields with <code>required</code> attribute and they should be <code>visible</code> too. Because page can have hidden required fields too. Here is what I tried:</p>
  
  <pre><code>function validateRequiredFields()
  {
      $('input,textarea,select').attr('required',true).filter(':visible:first').each(function(i, requiredField){
  
          if($(requiredField).val()=='')
          {
              alert($(requiredField).attr('name'));
          }
      });
  }
  </code></pre>