如何在键入时格式化文本框中的电话号码?

编程入门 行业动态 更新时间:2024-10-17 15:28:29
本文介绍了如何在键入时格式化文本框中的电话号码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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; }      }

更多推荐

如何在键入时格式化文本框中的电话号码?

本文发布于:2023-11-24 23:22:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627320.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:框中   电话号码   文本   如何在

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!