MaskedEditExtender 太难用了,没钱用
MaskedEditExtender 在执行规则方面做得很好,但我的用户在其文本框中输入内容时遇到了困难。
我想在 TextBox 获得焦点时选择它的所有内容。
常规的 JavaScript 解决方案不起作用。
onfocus="javascript:this.select();"
MaskedEditExtender 会干扰。
当 TextBox 获得焦点时,如何选择它的所有内容?
<asp:TextBox
ID="TextBoxPrice"
runat="server" />
<ajaxToolkit:MaskedEditExtender
ID="MaskedEditExtenderTextBoxPrice"
runat="server"
TargetControlID="TextBoxPrice"
Mask="9,999.99"
MaskType="Number"
MessageValidatorTip="False"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
InputDirection="RightToLeft"
AcceptNegative="None"
DisplayMoney="Left" />
<ajaxToolkit:MaskedEditValidator
ID="MaskedEditValidatorTextBoxPrice"
runat="server"
ControlToValidate="TextBoxPrice"
ControlExtender="MaskedEditExtenderTextBoxPrice"
Display="Dynamic"
IsValidEmpty="False"
EmptyValueMessage="Price is required"
InvalidValueMessage="Price is invalid"
MinimumValue= "0.01"
MinimumValueMessage="Price is too small"
MaximumValue="9999.99"
MaximumValueMessage="Price is too large" />
The MaskedEditExtender does a good job of enforcing the rules, but my users have trouble typing into its TextBox.
I want to select all the contents of my TextBox when it gains focus.
A regular JavaScript solution does not work.
onfocus="javascript:this.select();"
The MaskedEditExtender interferes.
How can I select all the contents of the TextBox when it gains focus?
<asp:TextBox
ID="TextBoxPrice"
runat="server" />
<ajaxToolkit:MaskedEditExtender
ID="MaskedEditExtenderTextBoxPrice"
runat="server"
TargetControlID="TextBoxPrice"
Mask="9,999.99"
MaskType="Number"
MessageValidatorTip="False"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
InputDirection="RightToLeft"
AcceptNegative="None"
DisplayMoney="Left" />
<ajaxToolkit:MaskedEditValidator
ID="MaskedEditValidatorTextBoxPrice"
runat="server"
ControlToValidate="TextBoxPrice"
ControlExtender="MaskedEditExtenderTextBoxPrice"
Display="Dynamic"
IsValidEmpty="False"
EmptyValueMessage="Price is required"
InvalidValueMessage="Price is invalid"
MinimumValue= "0.01"
MinimumValueMessage="Price is too small"
MaximumValue="9999.99"
MaximumValueMessage="Price is too large" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用这个脚本:
use this script: