本文介绍了如何在键入时格式化文本框中的电话号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法在将电话号码输入文本框时添加电话号码?
Is there a way to add the dasshes in a phone number while typeing it into a textbox?
推荐答案查看此链接,可以帮助它 www.c-sharpcorner/Forums/Thread/56356/ [ ^ ]
使用Masked Input Plugin .. 。这是代码和演示链接。 digitalbush/projects/ masked-input-plugin / 希望这会对你有帮助。 Hi, Use Masked Input Plugin...Here is the code and demo link. digitalbush/projects/masked-input-plugin/ Hope This will help You.
First First Imports System.ComponentModel
然后
Then
Dim MaskPhone As New MaskedTextProvider("0000-0000") 'Here you use the number of caracters所以当它的值出现时会带上面具 打字时你可以用它来我的JS是最简单的解决方案。 在源代码中你添加事件onKeyUp 例如:
So when the value it will come up with mask When typing you can use that to my JS would be the simplest solution. In Source you add the event "onKeyUp" Exemple:
<asp:TextBox ID="TextBoxPHONE" runat="server" CssClass="textbox" Width="65px" onKeyUp="Mascara('PHONE',this,event);" MaxLength="10" TabIndex="31" ></asp:TextBox></td>以下功能:
And the following function:
if (key! key = 9 &&! = 8) { switch (type) { case 'PHONE': if (tam> = 5 && tam <9) campo.value s.substr = (0, 4) + '-' + s.substr (4, 4); if (tam> = 6 && tam == 10) campo.value s.substr = (0, 5) + '-' + s.substr (5, 4); break; } }
更多推荐
如何在键入时格式化文本框中的电话号码?
发布评论