With these rules in mind, let's create the validation code for a text box named txt Phone: Private Sub txt Phone_Validate(Cancel As Boolean) Dim str Temp As String Dim str Phone As String Dim str Extension As String Dim int Result As Integer Const Default Area Code = "703" ' ' Remove all the grouping characters for ' now. ' str Temp = Replace(txt Phone, "(", "") str Temp = Replace(str Temp, ")", "") str Temp = Replace(str Temp, "-", "") str Temp = Replace(str Temp, " ", "") str Temp = Replace(str Temp, "X", "x") ' ' Break up the digits into the number and ' the extension, if any.' int Result = In Str(1, str Temp, "x", vb Text Compare) If int Result 0 Then str Extension = Mid(str Temp, int Result 1) str Phone = Left(str Temp, int Result - 1) Else str Phone = str Temp End If If Left(str Phone, 1) = "1" Then str Phone = Mid(str Phone, 2) End If If Len(str Phone) 10 Then Msg Box "Please enter a valid telephone number.", vb Exclamation Cancel = True Exit Sub End If ' ' Prepend the default area code ' If Len(str Phone) = 7 Then str Phone = Default Area Code & str Phone End If ' ' Build the new phone number ' txt Phone = "(" & Left(str Phone, 3) & ") " _ & Mid(str Phone, 4, 3) & "-" _ & Right(str Phone, 4) ' ' Add the extension, if any ' If str Extension I used a default area code of 703, which you can obviously change as needed.In this 10-Minute Solution, you'll learn how to validate and format a phone number.While we won't deal with international (non-US) phone numbers here, you can apply these techniques to your local phone number format.
Also it should not allow to enter any space, special charcter, as well as charcters. You can find an example in here S...-Java Script/6/ Hope this helps Mujahid Khaleel Web designing, development, E-commerce applications. Still iam unable to achive for writing the code for Phone No Validation.Google's common Java, C and Javascript library for parsing, formatting, storing and validating international phone numbers.The Java version is optimized for running on smartphones, and is used by the Android framework since 4.0 (Ice Cream Sandwich).If you're going to be using the application in different locations, you may want to store that information with the application user's profile, similar to the way that Windows stores your favorite locations for dialing.These functions check the validity of a UK business or domestic telephone number (including those associated with mobile networks) specified by the supplied parameter. premium lines, adult services, radio-paging services, numbers allocated for drama purposes etc.) are disallowed.We can even cleanse phone numbers at point-of-entry, so you can be sure they’re valid before they enter your database.With real-time phone verification, you can validate 10-digit telephone numbers at the point of capture to ensure you collect only accurate phone numbers.