使用 Masktype Time 的 MaskedEditExtender 时,如何覆盖不良行为?
当正确指定输入时,以下两行可以正常工作:
<asp:TextBox ID="MondayOpenTextBox" runat="server" MaxLength="5" />
<Ajax:MaskedEditExtender ID="MondayOpenMaskedEditExtender" runat="server"
TargetControlID="MondayOpenTextBox" AcceptAMPM="false" MaskType="Time"
Mask="99:99" />
如果用户输入“12”,然后按 Tab 键切换到下一个字段,则分钟数将填充为当前分钟数。这对于相关页面来说是不可取的。我要么想弹出一条错误消息,要么填写“00”作为跳过的数字。
这没有帮助:
<asp:RegularExpressionValidator runat="server" ID="ValidateMondayOpenTextBox"
ControlToValidate="MondayOpenTextBox" Display="Dynamic" ErrorMessage="X"
ValidationExpression="\d\d:\d\d" />
因为该字段显然是在轮到验证器时格式化的。
The following two lines work fine when input is correctly specified:
<asp:TextBox ID="MondayOpenTextBox" runat="server" MaxLength="5" />
<Ajax:MaskedEditExtender ID="MondayOpenMaskedEditExtender" runat="server"
TargetControlID="MondayOpenTextBox" AcceptAMPM="false" MaskType="Time"
Mask="99:99" />
If the user enters "12" then tabs to the next field, the minutes get populated with the current minute. This is not desirable for the page in question. I'd either like to popup an error message, or fill in "00" for the skipped digits.
This does not help:
<asp:RegularExpressionValidator runat="server" ID="ValidateMondayOpenTextBox"
ControlToValidate="MondayOpenTextBox" Display="Dynamic" ErrorMessage="X"
ValidationExpression="\d\d:\d\d" />
as the field is apparently formatted by the time the validator gets its turn at it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以设置 MaskedEdit< 的
AutoComplete
属性/a> 扩展为false
以防止它用当前时间填充空屏蔽字符:这样,您的验证器应该能够正确完成其工作。
You can set the
AutoComplete
property of your MaskedEdit extender tofalse
in order to prevent it from filling the empty masked characters with the current time:That way, your validator should be able to properly do its job.
要使其填充 :00,您可以将属性 AutoCompleteValue 设置为“99:00”
To get it filled with :00 you can set the property AutoCompleteValue to "99:00"