电话号码的遮罩文本框视图 [英] Mask Textbox view for a phone number

查看:89
本文介绍了电话号码的遮罩文本框视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试格式化文本框,以便当用户可以输入电话号码时,它将自动以以下格式输入:(999)999-9999

i am trying to format a text box so that when the users can type in a phone number and it would automatically put it in the following format :(999)999-9999

我尝试使用MaskedEditExtender,它可以工作,但与我需要的完全相反。

i tried using the MaskedEditExtender, it works but it does the complete opposite of what i need.

当我单击显示正确格式的字段时,但是一旦我将鼠标移出,它仍然仍然只显示9999999999

when i click on the field it shows the correct format, but once i mouse out it still only shows 9999999999

我该怎么做,以便用户仅键入数字,并在应该自动插入的地方加上短划线和括号(

how can i do it so that the user ONLY types in numbers and it puts dashes and parentheses where it's supposed to automatically(which it does now), but keep the format when i click out of it.

<asp:TextBox ID="txtSuperPhone" runat="server" CssClass="myinputstyle"  />
    <asp:MaskedEditExtender ID="mskSuperPhone" runat="server" TargetControlID="txtSuperPhone" Mask="(999)999-9999"/>


推荐答案

要回答您的问题,您必须将

To answer your question, you have to set the "ClearMaskOnLostFocus" to false on the extender for the mask to show all the time.

话虽如此....

我强烈建议您使用jquery替代方法。

I strongly suggest that you use the jquery alternative.

http://digitalbush.com/projects/masked-input-plugin/

我之所以说这是因为maskededitextender在野生动物园中不起作用。

The reason I say this is because the maskededitextender does not work in safari.

这篇关于电话号码的遮罩文本框视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆