Regular expressions are patterns used to match character combinations in strings.In Java Script, regular expressions are also objects.With all of this in mind, let’s look at the regular expression again after breaking it into its pieces. : # Group but don't capture: [0-9] # Match a digit. ITU-T Recommendation E.123 (“Notation for national and international telephone numbers, e-mail addresses and web addresses”) can be downloaded at Because this version is written using free-spacing style, the literal space character has been replaced with ^ # Assert position at the beginning of the string. ITU-T Recommendation E.164 (“The international public telecommunication numbering plan”) can be downloaded at RFC 5733 defines the syntax and semantics of EPP contact identifiers, including international phone numbers. Techniques used in the regular expressions in this recipe are discussed in Chapter 2. below is the code for validating mobile number with enter only numeric, length must be 10 digits and restrict user to entering illegal characters.There is two ways given below for validation of mobile numbers first normal way and another through regular expression.
This code validates a 10 digit phone number taken in any format and sets the phone number text field to the desired output format.
The first Text Box is Name that allows only characters and spaces.
This java Script code determine whether a user entered phone number in a common format that includes 0999999999, 099-999-999, (099)-999-9999, (099)9999999, 0, 099 999-9999, (099) 999-9999, 099.999.9999 and all related combinations For this we use this regular expression: /^\(?