title: jQuery matching pattern
body: <p>I'm trying to <strong>validate</strong> my inputs with jQuery before a form is sent.</p>
  
  <p>This is what my input fields look like when there is <strong>no value</strong> inserted in the database:</p>
  
  <pre><code>    &lt;input
        class="field"
        type="text"
        style="background-color: rgb(255, 255, 255);"
        value="" name="input_18748_388_1257894000_"/&gt;
  </code></pre>
  
  <p>This is what my input fields look like when there is <strong>an existing value</strong> inserted in the database:</p>
  
  <pre><code>    &lt;input
        class="field"
        type="text"
        style="background-color: rgb(255, 255, 255);"
        value=""
        name="input_18748_388_1257894000_46549876"/&gt;
  </code></pre>
  
  <hr>
  
  <p>I would like to:</p>
  
  <ul>
  <li><p>Check if the value is already in the database</p></li>
  <li><p>Check if the user want to replace an
  existing value by nothing or zero and
  disallow it.</p></li>
  <li><p>Check if the user is trying to
  insert 0 in a new field and
  disallow it.</p></li>
  </ul>
  
  <hr>
  
  <p><strong><em>Solved:</em></strong></p>
  
  <pre><code>  $("input[name^='input_"+var+"_']")
                  .each(function() {
                      if ($(this).attr('name').match(/^input_\d+_\d+_\d+_\d+/)
                          &amp;&amp; ($(this).val() == '' || $(this).val() &lt;= 0))
                      {
                          displayDialog("&lt;?=_('error')?&gt;")
                          flag_error = 1;
                          return false;
                      }
              });
      // Submit the form.
  </code></pre>