Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

regular expression javascript for phone number


// below is the regular expression worked for me in javascript
/^(((d{3})))[ ]d{3}[-]d{4}$/;
only accepts the number in the format like 
(###) ###-####
 Below are the exmples 
- (123) 123-3456
- (111) 234-4556


function isValidPhoneNumber(p) {
  var phoneRe = /^(((d{3})))[ ]d{3}[-]d{4}$/;
  return phoneRe.test(p);
}

you can call above function  with below code
var isValid= isValidPhoneNumber("(123) 123-3456)");

Comment

regex to check the phone number javascript

//To check that the phone number is of 10 digits
let regex=/^[0-9]{10}$/;
Comment

javascript regex check phone number

let pattern = /^[62|0]+d{10}/gi
let phone = '087887242822'
console.log(pattern.test(phone))
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery change href value 
Javascript :: how to start json server 
Javascript :: jquery Audio Play on button click 
Javascript :: dm someone by id discord.js 
Javascript :: veu scroll to top 
Javascript :: H. Nazmul 
Javascript :: express server template 
Javascript :: Get child node index 
Javascript :: how to get an even number in javascript 
Javascript :: set focus on input field javascript 
Javascript :: refresh page after delete angular 
Javascript :: js add css class to element 
Javascript :: discord.js get all members with role 
Javascript :: fetch data from api in react 
Javascript :: vue watch deep property 
Javascript :: vim total number of lines 
Javascript :: js replace all spaces 
Javascript :: axios upload progress react 
Javascript :: regex select string between two strings 
Javascript :: check if a class exists javascript 
Javascript :: redirect to url in javascript 
Javascript :: vehicle number yup validation 
Javascript :: jquery datepicker set default date 
Javascript :: enzyme debug 
Javascript :: how to edit /.prettierrc.json file pretter 
Javascript :: hover react component 
Javascript :: fs.readdir example 
Javascript :: check if array does not contain value javascript 
Javascript :: disable text selection in js 
Javascript :: (node:2736) DeprecationWarning: collection.ensureIndex is deprecated. Use createIndexes instead. 
ADD CONTENT
Topic
Content
Source link
Name
6+7 =