title: Form Validation Jquery Regular expression
body: <p>this is my Script :</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
      $(document).ready(function () {
          $.validator.addMethod(
          "regex",
          function (value, element, regexp) {
              var re = new RegExp(regexp);
              return this.optional(element) || re.test(value);
          },
          "Matricule Invalide"
  );
              $("form").validate({
                  rules: {
                      idv: { required: true, regex: "/^(\d{3})TN(\d{4})$/" },
                      dd: { required: true },
                      df: { required: true },
                      remise: { required: true, range: [0, 100] }
                  },
                  messages: {
                    idv: { required:"champs requis", regex: "Matricule Invalide"},
                    dd: "champs requis",
                    df: "champs requis",
                    remise : { required: "champs requis",
                               range: "Valeur doit entre entre 0 et 100"}
                  }
              });
          });
      &lt;/script&gt;
  </code></pre>
  
  <p>The IDV field has to be like this way "111TN000" or "222TN0123" in other ways it's regular expression: <code>Number of 3 digets +TN+ Number of Four digets</code>. I have created my regular expression <code>"/^(\d{3})TN(\d{4})$/"</code>, but the probleme here that when i put <code>Valide IDV</code> My Jquery Function show me always <code>Matricule Invalide</code>, This same Regulare expression works at Java and ASP.net. <br>I think i'm missing something very simple here?</p>