Validating phone number in javascript

Hi I need to validate my mobile number it wants to be in 91-1234567890 this format If i enter 1234567890 its wants to show alert message your mobile wants to be in 91-1234567890 format If i enter 9112345678901 its wants to show alert message your mobile wants to be in 91-1234567890 format If i enter 9112345678901 its wants to show alert message your mobile wants to be in 91-1234567890 format and then the correct mobile format 91-1234567890 wants to save in My sql database. If the application is india based then you can proceed with 91 as country code or keep an array of all country codes and change the validation accordingly. All i can say is investigate regular expressions this is a very simple one Hi Arun Please check this code. Also make use of component level of validation to restrict the user to enter only numerics and characters " " and "-" 2. Like everything in Java Script you can either create a regex pattern by using literal notation or by calling the constructor function of the ‘ More info on the two methods can be found here: Script_1.5_Guide/Regular_Expressions The first method (using a regex literal) is faster than the second but it compiles your pattern when the script is evaluated as opposed to the second method (Calling the object constructor) which compiles your pattern at runtime.So, if you wanted to include some variable data (perhaps from user input) in the pattern then using the object constructor is your only is an easy yet useful Java Script library used for identifying, formatting and validation phone numbers.Currently supports 13 countries: Argentina, Brazil, Canada, Chile, Colombia, Ecuador, Guatemala, Mexico, Paraguay, Peru, Uruguay, United Kingdom, USA.These patterns are used with the exec and test methods.In this article we will discuss about regular expression for validating Phone number in various format.

About a month ago I decided to begin on the long and tiresome journey of learning regular expressions. So, in this post I’m going to share some of the awesome things I’ve learnt so far on my "journey".Regular expressions are patterns used to match character combinations in strings.In Java Script, regular expressions are also objects.e.g: Like everything there is always more than one way to do things with regular expressions.As a simple example, let’s assume we need to test a string to confirm it is in the format of a phone number.For North American Numbering Plan (NANP) countries (including the United States and Canada) the call prefix is "011" for other countries and "1" for countries inside the NANP.


Leave a Reply

  1. Camsexswinger free 11-Nov-2017 09:53

    The Internet is a wonderful way to search for and be found by other Jacksonville singles.

  2. Desi sex chat instant online 13-Aug-2017 09:24

    Khalid Khan, lead study researcher and professor of women’s health at Queen Mary University of London, said choosing a profile name beginning with the letters A through M can have a positive influence on how other users view you.