title: How can I use preg_match in jQuery?
body: <p>Can I use preg_match to validate phone number in jQuery? Here is my code which does not work:</p>
  <pre><code>if (!preg_match(&quot;/^[0-9]{3}-|\s[0-9]{3}-|\s[0-9]{4}$/&quot;, phone.val() ))  {
              phone.addClass(&quot;needsfilled&quot;);
              phone.val(phonerror);
          }
  </code></pre>
  <p>HTML
  <code>&lt;input id=&quot;phone&quot; type=&quot;text&quot; value=&quot;&quot;  name=&quot;phone&quot; /&gt;</code></p>