title: How to disable a button if the input field not matches 10 digits
body: <p>I am very new to the UI part, i have one form which contains input type as number that field should accept only 10 digits only once the condition match i want to enable the submit button can you please help me did i miss anything ?</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
      $('#pnum').on('keypress', function(e) {
          var $this = $(this);
          var regex = new RegExp("^[0-9\b]+$");
          var str = String.fromCharCode(!e.charCode ? e.which : e.charCode);
          // for 10 digit number only
          if ($this.val().length &gt; 9) {
              e.preventDefault();
              return false;
          }
          if (e.charCode &lt; 54 &amp;&amp; e.charCode &gt; 47) {
              if ($this.val().length == 0) {
                  e.preventDefault();
                  return false;
              } else {
                  return true;
              }
  
          }
          if (regex.test(str)) {
          $('#submitButton').prop('disabled', false);
               return true;
          }
          e.preventDefault();
          return false;
      });
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!-- CSS only --&gt;
  &lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous"&gt;
  &lt;script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;div class="form-group"&gt;
      &lt;label for="exampleInputEmail3"&gt;Phone Number&lt;/label&gt;
      &lt;div class="input-group"&gt;
          &lt;div class="input-group-prepend"&gt;
              &lt;span class="input-group-text"&gt;+ 91&lt;/span&gt;
          &lt;/div&gt;
          &lt;input type="number" class="form-control" id="pnum" name="phone_number" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*?)\..*/g, '$1');" maxlength="10" required&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;input type="submit" name="submit" disabled id="submitButton" value="Submit" class="btn btn-primary mr-2"&gt;</code></pre>
  </div>
  </div>
  </p>