title: Dynamic input text box id doesnt match the regex format. shows undefined
body: <p>I have a dynamic input boxes having the following ids, points0, points1,points2 etc. I want to make sure that these input boxes shoould match only numbers. So I used the following code but in console it always shows </p>
  
  <blockquote>
    <p>TypeError: $(...).val(...) is undefined</p>
  </blockquote>
  
  <p>So I used the following code. I am looping over input text boxes.</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var result = document.getElementsByTagName("input");
  for (var j = 0; j &lt; result.length; j++) {
  var points = 'Enter a valid point.';
  var regex = '/^[A-Za-z!@#&gt;&lt;/!?\$%\^\&amp;*\)\(+=._-]+$/g';
   if ($("#points" + j).val().match(regex)) {
                      $('#points' + j + ' + span').html('');
                      $('#points' + j).after('&lt;span class="' + errTextboxClass + '" style="color:#e03b3b;"&gt;' + points + '&lt;/span&gt;');
                      $('#points' + j).focus();
                  }
    }
  
     </code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>In my Laravel blade I am looping some answers,</p>
  
  <pre><code> @if($ans)
   @for($j=0;$j&lt;count($ans) ;$j++)
   &lt;input class="form-control " name="points[]" id="points{{$j}}" placeholder="POINTS"  value="&lt;?php echo $ans[$j]['points'];?&gt;"&gt;
  @endfor
  @endif
  </code></pre>