Click here to Skip to main content
15,885,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a way to add the dasshes in a phone number while typeing it into a textbox?
Posted

Hi,

Check this link, can help it
http://www.c-sharpcorner.com/Forums/Thread/56356/[^]
 
Share this answer
 
Hi,
Use Masked Input Plugin...Here is the code and demo link.
http://digitalbush.com/projects/masked-input-plugin/
Hope This will help You.
 
Share this answer
 
v2
First
VB
Imports System.ComponentModel


Then
VB
Dim MaskPhone As New MaskedTextProvider("0000-0000") 'Here you use the number of caracters


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.NET
<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:

JavaScript
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;
             }
     }
 
Share this answer
 
v2
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900