title: JavaScript files.length not working in ie9 need alternative approach
body: <p>I have the following JavaScript function which is failing in internet explorer 9 on the line which declares the variable <code>filesattached</code>.</p>
  
  <pre><code>function VesselDetails() {      
  
      insurancestart = $('#ctl00_ContentPlaceHolder1_datetimepickerinsstart').val();
      insuranceend = $('#ctl00_ContentPlaceHolder1_datetimepickerinsend').val();
      filesattached = $("input:File")[0].files.length;  
  
      //set up JS objects
      $('#ctl00_ContentPlaceHolder1_datetimepickerinsend').datetimepicker({ format: 'd/m/Y H:i a' });
      $('#ctl00_ContentPlaceHolder1_datetimepickerinsstart').datetimepicker({ format: 'd/m/Y H:i a' });
  
      //subscribe to change events
      $('#ctl00_ContentPlaceHolder1_datetimepickerinsstart').change(function () {
          insurancestart = $("ctl00_ContentPlaceHolder1_datetimepickerinsstart").val();
      });
  
      $('#ctl00_ContentPlaceHolder1_datetimepickerinsend').change(function () {
          insuranceend = $("ctl00_ContentPlaceHolder1_datetimepickerinsend").val();
      });
  
      $("input:File").change(function () {
          filesattached = $("input:File")[0].files.length;
      });
  
      ins_client();
  }
  </code></pre>
  
  <p>The <code>ins_client</code> method looks like this:</p>
  
  <pre><code>function ins_client(sender, e) {
      if (pagemode == 'EditVessel') {
          e.IsValid = true;
      }
  
      if (pagemode == 'NewVessel') {
          if (insurancestart !== '' &amp;&amp; insuranceend !== '' &amp;&amp; filesattached &gt; 0) {
              e.IsValid = true;
          }
          else {
              e.IsValid = false;
          }
      }
  }
  </code></pre>
  
  <p>This all works perfectly well in chrome and ie 11 but the length property is returning an undefined for ie 9. I am using the length because I only want the page to be valid for a new vessel request once a document has been submitted, is there another way of doing this which will work in ie 9 onwards and chrome, apologies if this has already been answered elsewhere but I cannot find a workaround anywhere that enables this to continue working in the same way but in ie9 onwards and chrome.</p>