title: multiple file upload validation through array in jquery
body: <p>The below represents my script code</p>
  
  <pre><code>&lt;script&gt;
          $(document).ready(function (){    
              $("#checkfields").click(function (){
  
                  var file1=$("#file1").val();
                  if(file1){                        
                      var file_size=$('#file1')[0].files[0].size;
                      if(file_size&lt;2097152){
                          var ext = $('#file1').val().split('.').pop().toLowerCase();                            
                          if($.inArray(ext,['jpg','jpeg','gif'])===-1){
                              alert("Invalid file extension");
                              return false;
                          }
  
                      }else{
                          alert("Screenshot size is too large.");
                          return false;
                      }                        
                  }else{
                      alert("fill all fields..");         
                      return false;
                  }
              });
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>The below represents my code</p>
  
  <pre><code>&lt;form action="checkmobile.php" method="post" enctype="multipart/form-data" class="form-horizontal"&gt; 
  &lt;div class="form-group"&gt;
                          &lt;label for="element-13" class="control-label col-lg-2"&gt;Add Screenshots&lt;/label&gt;
                          &lt;div class="input-group"&gt;                            
                              &lt;input type="file" id="file1" name="file[]" class="btn" multiple="multiple"&gt;
                          &lt;/div&gt;
                      &lt;/div&gt;
  &lt;div class="form-group"&gt;
  
                                  &lt;input type="submit" id="checkfields" class="btn btn-primary  col-lg-offset-2" value="Add"&gt;
                                  &lt;button class="btn btn-default col-lg-offset-1"&gt;Cancel&lt;/button&gt;
                              &lt;/div&gt;
                  &lt;/form&gt;
  </code></pre>
  
  <p>Now I want to know how to use array in jQuery for validating all selected files under the input.</p>
  
  <p>If I select one image and one video then it must check validation for image and video. first it will validate image if image is ok then it will reject the video by invalid extension.</p>
  
  <p>i want to validation for all files while submitting the button and if image not valid then return error and if there is video selected with image then also it return error.</p>
  
  <p>please help.</p>