使用 KendoUI 的 .kendoMaskedTextBox,您将如何屏蔽特定字符?
Using KendoUI's .kendoMaskedTextBox, how would you mask specific characters?
我可以使用 KendoUI 的 .kendoMaskedTextBox
轻松屏蔽文本字段输入:
$("#MainContent_txtMailingZip").kendoMaskedTextBox({
mask: "L0L 0L0"
});
但是,我现在只想接受字母 M 和 L 作为第一个字符。
如何做到这一点?
我认为这不可能,以下是 API 文档中的有效掩码规则。 http://docs.telerik.com/kendo-ui/api/javascript/ui/maskedtextbox#configuration-mask
0 - Digit. Accepts any digit between 0 and 9.
9 - Digit or space. Accepts any digit between 0 and 9, plus space.
# - Digit or space. Like 9 rule, but allows also (+) and (-)
signs.
L - Letter. Restricts input to letters a-z and A-Z. This rule is
equivalent to [a-zA-Z] in regular expressions.
? - Letter or space. Restricts input to letters a-z and A-Z. This rule
is equivalent to [a-zA-Z] in regular expressions.
& - Character. Accepts any character. The rule is equivalent to \S in
regular expressions.
C - Character or space. Accepts any character. The rule is equivalent
to . in regular expressions.
A - Alphanumeric. Accepts letters and digits only.
a - Alphanumeric or space. Accepts letters, digits and space only.
. - Decimal placeholder. The decimal separator will be get from the
current culture used by Kendo.
, - Thousands placeholder. The display character will be get from the
current culture used by Kendo.
$ - Currency symbol. The display character will be get from the
current culture used by Kendo.
我在字段中添加了正则表达式验证。虽然它不满足按键过滤器,但它可以解决问题:
<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>
就是你想要的:
$("#MainContent_txtMailingZip").kendoMaskedTextBox({
mask: "^0L 0L0",
rules: { "^": /[ML]/ }
});
我可以使用 KendoUI 的 .kendoMaskedTextBox
轻松屏蔽文本字段输入:
$("#MainContent_txtMailingZip").kendoMaskedTextBox({
mask: "L0L 0L0"
});
但是,我现在只想接受字母 M 和 L 作为第一个字符。
如何做到这一点?
我认为这不可能,以下是 API 文档中的有效掩码规则。 http://docs.telerik.com/kendo-ui/api/javascript/ui/maskedtextbox#configuration-mask
0 - Digit. Accepts any digit between 0 and 9.
9 - Digit or space. Accepts any digit between 0 and 9, plus space.
# - Digit or space. Like 9 rule, but allows also (+) and (-) signs.
L - Letter. Restricts input to letters a-z and A-Z. This rule is equivalent to [a-zA-Z] in regular expressions.
? - Letter or space. Restricts input to letters a-z and A-Z. This rule is equivalent to [a-zA-Z] in regular expressions.
& - Character. Accepts any character. The rule is equivalent to \S in regular expressions.
C - Character or space. Accepts any character. The rule is equivalent to . in regular expressions.
A - Alphanumeric. Accepts letters and digits only.
a - Alphanumeric or space. Accepts letters, digits and space only.
. - Decimal placeholder. The decimal separator will be get from the current culture used by Kendo.
, - Thousands placeholder. The display character will be get from the current culture used by Kendo.
$ - Currency symbol. The display character will be get from the current culture used by Kendo.
我在字段中添加了正则表达式验证。虽然它不满足按键过滤器,但它可以解决问题:
<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>
就是你想要的:
$("#MainContent_txtMailingZip").kendoMaskedTextBox({
mask: "^0L 0L0",
rules: { "^": /[ML]/ }
});