Javascript function for validating phone number

This would need to be updated for international numbers, or to allow users to enter phone numbers using letter representation.

In a real case, this function would probably be called as part of a larger validate form function.

If the phone number was invalid, we would want to return false to cancel form submission as well as informing the user of the errors of their ways.

This code validates a 10 digit phone number taken in any format and sets the phone number text field to the desired output format.

Just set the Character length( Maximum and minimum) of the field, please see the attached Screenshot for reference.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions.

It gives an alert message if user enters data other than numbers. First argument is html / server control value, which is entered by user. There is one javascript function called "Validate No". Num Str : This is the value which you want to validate. It may by Text Box control (HTML or Server Control). String : This is predefined format which you can use to validate phone/fax number.

The first Text Box is Name that allows only characters and spaces.

Search for javascript function for validating phone number:

javascript function for validating phone number-40javascript function for validating phone number-50javascript function for validating phone number-47

This notation requires that international phone numbers include a leading plus sign (known as the ), and allows only spaces to separate groups of digits. EPP is a relatively recent protocol (finalized in 2004), designed for communication between domain name registries and registrars.

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “javascript function for validating phone number”

  1. He's getting on with life, going to school, and on the surface seems to have adjusted well, but underneath a complex set of emotions are surging. See full summary » In August 1966, in a Vietnamese rubber plantation called Long Tan, 108 young and inexperienced Australian and New Zealand soldiers are fighting for their lives against 2500 North Vietnamese and Viet Cong soldiers.

  2. To be user friendly across sectors within the UK and across countries in the EU, servers and gateways need to be as simple as possible, so that they attract maximum use. Another concern of any subject-based server and gateway is that of cognate subjects, and discussion is in progress with sites which might offer resource discovery in theology, philosophy, art history and archeology.