title: Using regex to restrict input in textbox
body: <blockquote>
    <p>/^+{0,1}(?:\d\s?){11,13}$/ this regex allows + at first place only and numbers only...</p>
  </blockquote>
  
  <p>on keypress I want user should only be able to type + at first and digits that what above regex validates But code always goes to if part..why regex not working in this scenario</p>
  
  <pre><code>function ValidatePhone(phone) {
              var expr = /^\+?(?:\d\s?){11,13}$/;
              return expr.test(phone);
          }
  
  
  var countofPlus = 0;
  
      $("#phone").on("keypress", function (evt) {
          if (evt.key == "+")
          {
              countofPlus = countofPlus + 1;
              if (countofPlus &gt; 1 || this.value.length &gt;= 1) {
                  return false;
              }
              else return true;
          }
          var charCode = (evt.which) ? evt.which : event.keyCode
          if (charCode &gt; 31 &amp;&amp; charCode != 43 &amp;&amp; charCode != 32 &amp;&amp; charCode != 40 &amp;&amp; charCode != 41 &amp;&amp; (charCode &lt; 48 || charCode &gt; 57))
              return false;
          return true;
      });
  $("#phone").on("keyup", function (evt) {
          debugger;
          if (evt.key == "+") {
              countofPlus--;
              return true;
          }
  
      });
  </code></pre>