title: Validation of input elements haing name as array
body: <p>I have textbox and upload file like:</p>
  
  <pre><code>&lt;input type="text" id = "contract_copy_text[]" name="contract_copy_text[]" value="" maxlength="50"/&gt;
  &lt;input type="file" name="contract_copy_pdf[]" id="contract_copy_pdf[]" accept="application/pdf" /&gt;
  </code></pre>
  
  <p>I am not able to validate it.</p>
  
  <p>I have tried :</p>
  
  <pre><code>var contract_copy_text = $('#contract_copy_text[]').val(); // document.getElementById('contract_copy_text').value;
      var contract_copy_pdf = $('#contract_copy_pdf[]').val(); // document.getElementById('contract_copy_pdf').value;
  
      if (contract_copy_text == "") {
          alert("insert contract copy title for file");
          $('#err_lbl_contract_copy_text').html('insert contract copy title for file');
          return false;
      }
  
      if (contract_copy_pdf == "") {
          alert("Please select contract copy pdf file for upload");
          $('#err_lbl_contract_copy_pdf').html('Please select contract copy pdf file for upload');
          return false;
      }
  </code></pre>
  
  <p>But that doesn't work.</p>
  
  <p>Please note: These fields are dynamically generated as required(on click).
  Can anyone tell me what mistake I am making.</p>
  
  <p>UPDATE:</p>
  
  <p>Please see <a href="http://jsfiddle.net/salunkheganesh07/fve8sbut/" rel="nofollow">fiddle</a></p>