Jquery validate regex not working
<p>I want to check whether an input box has only numbers or not. I tried using regex as well as pattern. It doesn't give me any error messages. Can someone help me out? Thanks.</p>

<p>Here's my code</p>

<pre><code>&lt;script type="text/javascript" src="https://code.jquery.com/jquery-2.1.1.min.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"
        src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.7/jquery.validate.min.js"&gt;
&lt;/script&gt;

&lt;form id="signupForm" class="col s6 m6 offset-m3 offset-s3" th:action="@{/signup}" method="post"&gt;
  &lt;div class="col s12"&gt;
    &lt;div class="row"&gt;
      &lt;div class="input-field col s12 m10 offset-m1 offset-s2"&gt;
        &lt;input id="universityid" name="universityId" th:value="${user.universityId}"
               minlength="6" maxlength="6" required="required" type="text" class="validate"/&gt;
        &lt;label for="universityid"&gt;University Id(Numbers Only)&lt;/label&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p>Here's my jquery code</p>

<pre><code>$('#signupForm').validate({
    rules: {
        universityId: {
            pattern: /^[0-9]+$/
        }
    },
    messages: {
        universityId: {
            pattern: "Only numbers are allowed"
        }
    }
});
</code></pre>