title: Validation User input using javascript
body: <p>I am novice in php, html and javascript. My aim is to check and validate the user input. My code is working only for one input field which is not in loop. In a moment, I want to check multiple input fields from loop the reply of the code is &quot;* Wrong Insert: undefined, position: null&quot;.</p>
  <p>Would you be so kind and tell me what am I doing wrong ?</p>
  <p>javscript block</p>
  <pre><code>    function ValidationSubmit()
      {
  
           var DatabaseIndex = document.getElementById(&quot;3&quot;).getAttribute(&quot;name&quot;);
  
           var CheckInt    = document.getElementById(&quot;3&quot;);
           var CheckIntVal = CheckInt.value;
           const a=-10;
           if( a &lt; 0 )
           {
              document.getElementById('demo').innerHTML = &quot;* Wrong insert : &quot; + CheckIntVal + &quot;, position: &quot; + DatabaseIndex ;
            return false;
           }
  
           else
           {
            return true;
           }
  </code></pre>
  <p>php block for calling validation function ValidationSubmit()</p>
  <pre><code>echo '&lt;form method=&quot;POST&quot; target=&quot;_top&quot; action=&quot;SaveForm.php?UID='.$UID.'&quot; onsubmit=&quot;return ValidationSubmit()&quot;&gt;';
  </code></pre>
  <p>php block for user input</p>
  <pre><code>
  $j = 0;
  while($j&lt;=10)
          {
          $ID    = strval($j);
          echo &quot;&lt;td&gt;&lt;input type='text' id='$ID' name='$ID' value='$value[$j]'  &gt;&lt;/td&gt;&quot;;
  
          $j++;
          }
  
  </code></pre>