title: input field with "xxx-xxxxxxx-yy" need to be validated
body: <p>I am trying with a validation for an number format and the number should be automatically replaced in the character while typing.</p>
  
  <p>The format is: xxx-xxxxxxx-yy AND in another field "xx-xx-xx-xxx-xx"</p>
  
  <p>My Code:</p>
  
  <pre><code>$('#id_number').on("keypress keyup blur", function(event) {
          $('span.error-keyup-1').hide();
          var inputVal = $(this).val();
          $(this).val($(this).val().replace(/[^0-9\.]/g, ''));
          var numericReg = /^\d*[0-9](|.\d*[0-9]|,\d*[0-9])?$/;
          if(!numericReg.test(inputVal)) {
              $(this).after('&lt;span class="error error-keyup-1"&gt;Numeric characters only.&lt;/span&gt;');
          }
      });
  </code></pre>
  
  <p>I have come up till allowing numeric. But replacing the character with number while user type.. becomes difficult.</p>
  
  <p>Can some one help me. Is there any regex?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
   $('#id_number').on("keypress keyup blur", function(event) {
    $('span.error-keyup-1').hide();
    var inputVal = $(this).val();
    //$(this).val($(this).val().replace(/[^0-9\.]/g, ''));
    var numericReg = /^(?:\d{3}(?:-\d{7})?(?:-\d{2})?|\d{2}(?:(?:-\d{2}){0,2})?(?:-\d{3})?(-\d{2})?)$/gm;
    if(!numericReg.test(inputVal)) {
     $(this).after('&lt;span class="error error-keyup-1"&gt;Numeric characters only, and pattern should match either "xxx-xxxxxxx-yy" or "xx-xx-xx-xxx-xx".&lt;/span&gt;');
    }
   });
    });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;div class="inp-wrap"&gt;
  &lt;input type="text" class="form-control" id="id_number" name="id_number" maxlength="20" required&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>