Search code examples
javascriptkendo-uimasking

Using KendoUI's .kendoMaskedTextBox, how would you mask specific characters?


I can easily mask a text field input with KendoUI's .kendoMaskedTextBox:

$("#MainContent_txtMailingZip").kendoMaskedTextBox({
    mask: "L0L 0L0"
});

However, I would now only like to accept the letters M and L for the first character.

How would one accomplish this?


Solution

  • I added a regex validation to the field. While it doesn't satisfy the keypress filter, it does the trick:

        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" CssClass="field-validation-error" ErrorMessage="<%#ResourceApplicantIntakeCustomerInformation.msgInvalidPostalCode%>" ControlToValidate="txtMailingZip" ForeColor="red" Enabled="true" 
            ValidationExpression="^[KLMNP][0-9][A-Z] ?[0-9][A-Z][0-9]$"></asp:RegularExpressionValidator>