CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Formating a phone number

Print topic Send  topic

Author Message
netcrawler

Posts: 3
Posted: 11/16/2004, 4:26 AM

I need a ASP.Net/VB method to take all the diffent ways someone might enter a phone number.

(222) 222-222
222-222-2222
2222222222
222 222 2222
1 222 222 2222
12222222222

and convert it to (222) 222-2222

Any one have a good solution?
Thanks
View profile  Send private message
netcrawler

Posts: 3
Posted: 11/16/2004, 4:30 AM

Quote netcrawler:
I need a ASP/VB method to take all the diffent ways someone might enter a phone number.

(222) 222-222
222-222-2222
2222222222
222 222 2222
1 222 222 2222
12222222222

and convert it to (222) 222-2222

Any one have a good solution?
Thanks

I modified the above I need a ASP/ VB no need for a ASP.net...
View profile  Send private message
Sean

Posts: 39
Posted: 11/16/2004, 7:10 AM

Why not use the iput mask example the way they do in the following:

http://examples.codecharge.com/ExamplePack/InputMask/InputMask.php

It uses JavaScript to format it for you so it is always exactly how you want it.
View profile  Send private message
Robert Rodgers
Posted: 11/16/2004, 4:18 PM

I use this in an internal app.

It checks for a valid number then formats the numbers,



onblur="validphone({HTMLFormName}.{PhoneNumber_Name})"

<script language="VBScript">
<!--
Sub ValidPhone(xObj)
Dim xChar
Dim xTempNumber

For xLoopCount = 1 To Len(xObj.Value)
xChar = Mid(xObj.Value,xLoopCount,1)
If IsNumeric(xChar) = True Then
xTempNumber = xTempNumber & xChar
End IF
Next

If Len(Trim(xTempNumber)) = 0 Then
xObj.Value = ""
MsgBox "Phone Number is a required Field"
xObj.Focus
Exit Sub
End If

If Len(Trim(xTempNumber)) < 10 Then
xObj.Value = xTempNumber
MsgBox "Phone Number is required to be at least 10 characters."
xObj.Focus
Exit Sub
End IF

xObj.Value = "("
xObj.Value = xObj.Value & Mid(xTempNumber,1,3)
xObj.Value = xObj.Value & ") "

xObj.Value = xObj.Value & Mid(xTempNumber,4,3)
xObj.Value = xObj.Value & "-"
xObj.Value = xObj.Value & Mid(xTempNumber,7,4)

If Len(Trim(xTempNumber)) > 10 Then
xObj.Value = xObj.Value & " x"
xObj.Value = xObj.Value & Mid(xTempNumber,11)
End IF

End sub
-->

</script>








"netcrawler" <netcrawler@forum.codecharge> wrote in messagenews:64199f1ecade59@news.codecharge.com...
I need a ASP.Net/VB method to take all the diffent ways someone might enter a
phone number.

(222) 222-222
222-222-2222
2222222222
222 222 2222
1 222 222 2222
12222222222

and convert it to (222) 222-2222

Any one have a good solution?
Thanks
---------------------------------------
Sent from YesSoftware forum
http://forums.codecharge.com/


Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.