title: Only JavaScript Dynamic Array Field Validation
body: <p>I think so there is a problem with for statement??</p>
  
  <p>Adjusted code again, but not alert popup is all the time even if all the input fields got values?</p>
  
  <p>Hello I am trying to validate a dynamic array of fields on a form:</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;form onsubmit="return checkReq();"&gt;
      &lt;input value="" type="hidden" name="slider[]" id=""/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>with the following JavaScript, but it doesn't work? Could you tell me please what I am doing wrong.</p>
  
  <pre><code>    &lt;script language="javascript"&gt;
      function checkReq () {
          var boxes = document.getElementsByName("slider[]");
      var ret = true;
      for (var x = 0; x &lt; boxes.length; x++) {
  
          if(boxes[x].value == '' || '0'){
              ret = false;
              break;
              } else {ret = true;} 
  
           }
     if (ret == false)
     {
       alert('Problem'); return ret;        
     }
  }
      &lt;/script&gt;
  </code></pre>