如何在键入时格式化文本框中的电话号码? [英] how do I format a phone number in textbox while typeing?

查看:43
本文介绍了如何在键入时格式化文本框中的电话号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在将电话号码输入文本框时添加电话号码?

Is there a way to add the dasshes in a phone number while typeing it into a textbox?

推荐答案





查看此链接,可以帮助它

http://www.c-sharpcorner.com/Forums/Thread/56356/ [ ^ ]




使用Masked Input Plugin .. 。这是代码和演示链接。

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

希望这会对你有帮助。
Hi,
Use Masked Input Plugin...Here is the code and demo link.
http://digitalbush.com/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;
             }
     }


这篇关于如何在键入时格式化文本框中的电话号码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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