Search code examples
javascriptkendo-uimaskingmaskedtextboxkendo-maskedtextbox

Kendo Mask Custom Rule


I've setup the following custom rule in a Kendo UI MaskedTextBox:

rules: {
    "~": /[0-9#]/
}

I thought this would allow 0-9 or # in the field, but the mask text of ~ shows up and the masked box won't let me enter anything.

Where am I going wrong with the custom mask? How do I configure a custom mask which will allow entry into the masked text box?


Solution

  • I was unable to duplicate the asker's problem, but the following code should achieve the requested behavior:

    <script>
      $(document).ready(function() {
         $("#with_mask").kendoMaskedTextBox({
           mask: "~~~~~~~~~~",
           rules: {
                   "~": /[0-9#]/
                  }
          });
       });
    </script>
    

    This Fiddle contains a working example.


    These Kendo documentation links might be useful for any further problems: