Share on Google+Share on Google+

Java Coder
Phone number validation using regular expression
2 Answer(s)      6 years and 2 months ago
Posted in : JavaScript Questions

Explain phone number validation using regular expression in JavaScript.

Ads

View Answers

February 23, 2011 at 5:45 PM


phone = phone.replace(/[^0-9]/g, '');
if(phone.length != 10) { 
   alert("not 10 digits");
} else {
  alert("yep, its 10 digits");
}


February 26, 2011 at 11:41 AM


function confirm1() {
var PhoneNo=document.getElementById("<%=txtPhoneNo.ClientID %>");

var PhoneNoExp = /^[0-9]+$/;

              if (!PhoneNo.value == "") 
            {

              if (!PhoneNo.value.match(PhoneNoExp)) 
              {
                alert("Only numbers are allowed for Phone No \n");
                PhoneNo.focus();
                return false;
              }   
            }

}










Related Tutorials/Questions & Answers:
Phone number validation using regular expression
Phone number validation using regular expression  Explain phone number validation using regular expression in JavaScript.   phone = phone.replace(/[^0-9]/g, ''); if(phone.length != 10) { alert("not 10 digits
regular expression for phone number
regular expression for phone number  Hi, i need the regular expression code for phone number in PHP. Thanks.   PHP - regular expression code for phone number \+?([0-9]{2})-?([0-9]{3})-?([0-9]{6,7
Advertisements
Java validate phone number using regular expression
Java validate phone number using regular expression In this tutorial, you will learn how to validate the phone number using regular expression. The user...("Enter Phone Number: "); String phone = input.nextLine
using regular expression
using regular expression  How can we extract string 'abc.com ' from a string http:[email protected] using regular expression of php
validation of date,phone number,email - Java Beginners
validation of date,phone number,email  Sir how to validate date,phone number and email in java swings  Hi Friend, Try the following code...)"); t1=new JTextField(20); l2=new JLabel("Enter Phone Number
Retrieving String by using Regular Expression
Retrieving String by using Regular Expression  ... the way to retrieve the String using Regular expression. For this we are going...:- Phone number is: 91.9789900009933 DownLoad Source Code
Regular expression
Regular expression  how i write a regular expression for a pattern which present in between
Regular expression
Regular expression  I have the regular expression : var x=/(^\d+$)/ which allows only numbers. It does not accept character, decimals. However it accepts zero. I want an expression that takes numbers(no decimals)except zero
Reset the matcher using regular expression
Reset the matcher using regular expression  ... the String using regular expression. For this we are going to make program named...):- Creating a pattern object and compiles the given regular expression
Pattern resetting using regular expression
Pattern resetting using regular expression  ... the String using regular expression. For this we are going to make program named... a pattern object and compiling the given regular expression into a given pattern
Regular expression
Regular expression  can some one explain how below regex works, ndmurl1=${ndmurl#${ndmurl
Regular expression
Regular expression  how i extract string Coalition of civil society organizations and CSOs from string:- CSOs : What happening in Yemen is political crisis SANA'A, May 16 (Saba)- Coalition of civil society organizations (CSOs
A regular expression contains another regular expression - PHP
A regular expression contains another regular expression   Please explain how it works in PHP... RegEX1 = "a.*b"; RegEx2 = "a1.*b"; Thanks
javascript regular expression
javascript regular expression  i need a regular expression code for JavaScript
regular expression for special characters
regular expression for special characters  How to find out regular expression for special characters
split string with regular expression
split string with regular expression  How to split string with regular expression in Java
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
URL Regular Expression for Struts Validator
URL Regular Expression for Struts Validator  I want to know how to validate a url link in struts validation.xml. Please share me the regular expression for url link validation
Parsing a String into Paragraphs Using a Regular Expression
Parsing a String into Paragraphs Using a Regular Expression       This section tells you how to parse the string into the paragraphs using regular expression in Java
Pointing and indicating matcher using regular expression
Pointing and indicating matcher using regular expression... to point the matcher and also indicate the index of the matcher using regular expression. For this we are going to make program named Indicating_Matcher.java.
java regular expression
java regular expression  hi i need java expression which allows all characters with minimum 2 characters and maximum 20 characters in answers field after selecting security questions
PHP Regular Expression
strings. PHP Regular expression also allows you to validate a email, phone...PHP regular expression allows programmer to perform various task like comparing, finding and replacing a particular type of strings. Using Regular
Regular expression in c++{MFC}
Regular expression in c++{MFC}  Hi ALL, I want to build a regular expression in c++{MFC} which validates the URL. The regular expression must... of %5C & %2F character. How can we develop a generic Regular Expression
Regular expression contains character - PHP
Regular expression contains character  A PHP script that can check if the regular expression contains character
Match string using regular expression without Case sensitivity
Match string using regular expression without Case sensitivity... the way to match the String using regular expression. For this we are going to make... is:- java has classes Java has methods JAVA have regular expressions
How can we extract string 'roseindia.net ' from a string http:[email protected] net using regular expression of php?
:[email protected] net using regular expression of php?   How can we extract string 'roseindia.net ' from a string http:[email protected] net using regular expression of php
Finding word using regular expression
Finding word using regular expression   ... the String using expression. For this we are going to make program named... the given regular expression into a pattern. String text = " JavaSun's regex
Regular expression in PHP for email - PHP
Regular expression in PHP for email  can any one tell me how to write regular expression in PHP for email to retrieve all the valid email ID's from the email
Matching Zip code using regular expression
Matching Zip code using regular expression  ... code with the regular expression .For this we are going to make program named...;:-This is the regular expression use to match with Zip code. matchZip("45643-44435"
What is regular expression beginning of line ?
What is regular expression beginning of line ?  Hi, I one of my Java program I have to write a program to find the beginning of a line and then replace the text using replaceAll() function of String. What is regular expression
Finding start and end index of string using Regular expression
Finding start and end index of string using Regular expression... the way for finding start and end index of the string using regular expression... a pattern object and compiling  the given regular expression into a pattern
Tutorials   
Java Spring Hibernate Struts Training code for programming How can I dynamically load user-entered data as content of jquery dialog? java webcam integration question java coding Fix Scrollbar position in a checkboxList after postback Information Save Alert Country wise redirection to files Interface in javascript connect database with javascript Zip Code ZipCode how to validate the email login How to play FLV video files on Ipad using HTML code or javascript code? Nitobi Grid is not working in IE10/IE11 jquery issue plese help RegEx Tree structure from json whose parents can be dragged and dropped from child newyorklife insurance getElementById not working javascript code for search in html file Implement The Skeleton Code Implement This Skeleton Code Mobile Automation using Appium Computer forensic application Java: Searching a string from doc files java linked list urgent !!! java linked list urgent!!! library management library management library management library management question Html form using JavaScript to display the table content java how to prevent no from unroundin off on clicking text box again in JSP and Jquery graph generation from xml design file display data from database in textbox when id entered in textbox Javascript Code for all fields how to get HTTP GET request value using javascript array Javascript Querry autocomplete(): Spring mvc with jquery: I am not getting correct value in the text filed. Please help me Create SpreadSheet same as excel using java applet Create SpreadSheet same as excel using java applet How to change focus among multiple select boxes? Write JQUERY Code Write JQUERY Code Converting jsp variable to java variable java

Ads

 
Advertisement null

Ads