Javascript telephone number validation [duplicate] - javascript

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Phone Number Validation Javascript
Hi I am creating validation for a form using javascript.
I am wanting to check the telephone number field using if statements to ensure it contains a 4 digit area code then a space followed by a 7 digit number.
Any help would be appreciated.
Thanks

So you need to validate something like 1234 1234567
function isValidTel(numberToTest){
var pattern =/^\d{4} \d{7}$/
return pattern.test(numberToTest);
}

Related

How can I extract number from text with regular expression [duplicate]

This question already has answers here:
Get price value from a string
(7 answers)
Closed 3 years ago.
I am trying to extract number from title. I have title like this:
**
Apartment London, 230.400€, 450,00m2
**
I want to extract only this price number (230.400€), can anybody help me with this?
So far my code look like this
\d+\.?\d+(.)
You can include the amount symbol as part of your RegEx:
/\d+\.?\d+(.)€/
Or you can try using Positive lookahead:
\d+\.?\d+(.)(?=€)

How can I use regular expression for multiple values [duplicate]

This question already has answers here:
Comma Separated Numbers Regex
(6 answers)
Closed 6 years ago.
I am trying to generate a regex which would match the following sequence-
+911111111111,+912222222222,+913333333333,+914444444444
It should not allow any other character other than + and numbers
I have tried this->
/^(\+91)\d{10}$/
But it works only for one phone number not for multiple phone numbers
If
^\+\d{11}$
(a + followed by 11 digits) is not sufficient you'll need to be more specific about what you want to allow and not-allow.
Update following comment: the first two digits are "91" so those can be specified, and then ten further digits:
^\+91\d{10}$

regex for phone number format (with dot) [duplicate]

This question already has answers here:
How to validate phone numbers using regex
(43 answers)
Closed 8 years ago.
Can somebody give me the regex for validating the phone numbers 000.0000.000000 and also without the dots.
sample numbers
880.1817.087511
and
8801817087511
try this.
\b\d{3}[.]?\d{4}[.]?\d{6}\b

How to get text equivalent of a number in JavaScript [duplicate]

This question already has answers here:
JavaScript numbers to Words
(28 answers)
Closed 8 years ago.
How to convert numeric number to their text equivalent?
Example:
Suppose if I type 3 or 23 in the text box, I want their text equivalent of three or twenty three, is this possible?
See this answer for more details:
JavaScript numbers to Words
And for a working implementation:
http://javascript.about.com/library/bltoword.htm
This will help you to achieve your task.
Number To Word

regular expression phone number [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
A comprehensive regex for phone number validation
Can somebody give me the regex for phone number. It can be entered in the format of XXX-XXX-XXXX or (XXX)-XXX-XXXX or XX-XXX-XXXX or XXXXXXXXX
Heres what I have:
/\d{2,3}-\d{3}-\d{4}$/
Brute force/easily maintained/easily read/I think is what you have.
(\d\d\d\-\d\d\d\-\d\d\d\d)|(\(\d\d\d\)\-\d\d\d\-\d\d\d\d)|(\d\d\-\d\d\d\-\d\d\d\d)|(\d\d\d\d\d\d\d\d\d)
Or if you prefer:
(\d{3}\-\d{3}\-\d{4})|(\(\d{3})\-\d{3}\-\d{4})|(\d{2}-\d{3}\-\d{4})|(\d{9})
((\d{2,3}|\(\d{3}\))-\d{3}-\d{4}|\d{9})
Mostly you care about the digits:
/^([()-]*\d)[()-]*){9,10}$/.test(string);
or even
/^(\D*\d\D*){9,10}/.test(string);

Categories

Resources