Home » Asp.netRSS

Format phone number in asp.net textbox control

Hi,

 I have a <asp:textbox> control, I want to display text as a phone number format like phone number mask.

Anybody can help on this. Thanks in advance.

 

11 Answers Found

 

Answer 1

Download the free ASP.NET Toolkit and use the masked edit box, there's a sample of the box

here : http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx 

and the download page http://www.asp.net/AJAX/downloads/ 

 

Answer 2

Hi,

I would like to know what should I download either "ajaxcontroltoolkit.zip" or  "ajaxcontrol toolkit-nosource.zip" from ajaxcontrolTOOLKIT with ajax extension1.0

 

 

Answer 3

ajaxcontroltoolkit.zip, it has a VS project in there with examples that you can look at

 

Answer 4

Any other idea with javascript

 

Answer 5

http://javascript.internet.com/forms/format-phone-number.html

There are a bunch of examples if you search for "format phone  number + javascript"

 

Answer 6

Try this:

<script type="text/javascript">
<!--
String.prototype.replaceAll = function (replaceValue, newValue)
{
 var functionReturn = this;

 while ( true )
 {
  var currentValue = functionReturn;

  functionReturn = functionReturn.replace(replaceValue, newValue);
  if ( functionReturn == currentValue )
   break;
 }

 return functionReturn;
};
toTelephoneNumber = function (valueToFormat)
{
 var parsedValue = new String(valueToFormat);

 parsedValue = parsedValue.replaceAll('-', '');
 parsedValue = parsedValue.replaceAll('(', '');
 parsedValue = parsedValue.replaceAll(')', '');
 parsedValue = parsedValue.replaceAll(' ', '');

 if ( parsedValue.length >= 10 )
 {
  var stringTemp = new String('');

  stringTemp = '(' + parsedValue.substr(0, 3) + ') ';
  stringTemp += parsedValue.substr(3, 3);
  stringTemp += '-';
  stringTemp += parsedValue.substr(6, 4);

  parsedValue = stringTemp;
 }

 return parsedValue;
};

var formattedValue = toTelephoneNumber('1231231234');
alert(formattedValue);
// -->
</script>

NC...

 

Answer 7

cameron_w:

Download the free ASP.NET Toolkit and use the masked edit box, there's a sample of the box

here : http://www.asp.net/AJAX/AjaxControlToolkit/Samples/MaskedEdit/MaskedEdit.aspx 

and the download page http://www.asp.net/AJAX/downloads/ 

 

The only reason I created an account was to tell you thank you so very much for your answer to this question. For the past few days I have been trying to figure out how to have a mask  in a text  field... and also what a mask was... and now with this links I was able to find out what I needed. 

 

Thank you. 

 

Answer 8

I followed this advice, downloaded and installed the Ajax controls.  A good number  of controls are now available, however the masked edit control  is not.  Not sure how to go about getting it.  Does anyone have any ideas? 

 

Answer 9

What version of ASP.NET/Visual Studio are you using?

 

Answer 10

Visual Studio 2008 Version 9.0.30729.1 SP

.NET Framework 3.5 SP1

 

 

Answer 11

This should get you what you need. This is exactly what I used to get it.

(asp.net/ajaxlibrary/act.ashx) (asp.net/ajaxlibrary/act_MaskedEdit.ashx)

 

 

 

Just in case, here is another link to something else.

 

http://www.asp.net/ajax/ajaxcontroltoolkit/Samples/MaskedEdit/MaskedEdit.aspx

 

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter