phone validator

Validate a phone number

Options

Using with form field

* presents a required option. The HTML attributes are used to set the validator options via the Declarative plugin

Name HTML attribute Type Description
country* data-fv-phone___country String or Function An ISO-3166 country code
message data-fv-phone___message String The error message

Tip

Since the plugin doesn't support HTML 5 type="tel" attribute, you should use type="text" instead

If you want to support custom formats of a phone number, you should use the Transformer plugin.

The validator supports the following countries (click the sample number to validate it):

Country Country code Sample Is it valid?
United States US 1444-555-1234
246.555.8888
1235554567
(123)456-7890
123)456.0987
1-444-555-1234
14325678901
1(123)456-7890
+1 246.555-8888
+1 (123)456-7890
+1(123)456-7890
7334-12.111
v123.11.1111
(23)440.4448
123(456)7890
0800 333333 abcdef
United Arab Emirates AE 00971501234567
+971521234567
971551234567
971 56 123 4567
971-50-123-4567
971.4.123.4567
+971 (0) 4 1234567
971 (56) 1234567
0551234567
021234567
600-540-000
Bulgaria BG 359895123456
0898111222
0886111222
0875111222
0899555555
359898111222
00898111222
+35998111222
098111222
090012900
070010007
070043256
35970045045
35970045666
08000700
080088001
080015333
028700000
030100000
03010070
03656745
01211212
Brazil BR 0800.000.00.00
0800-000-00-00
0800 000 00 00
0800-00-00-00
0800.00.00.00
0800 00 00 00
0800-000-0000
0800 000 0000
0800.000.0000
08000000000
1692089-4635
16920894635
16992089-4635
16 99202-4635
(16)99202-4635
(16)92089-4635
(16) 92089-4635
(15) 4343-4343
+55 15 3702-7523
(+55)1537027523
(+55)(15)3702-7523
(+55) 15 3702-7523
(+55) 15 99202-7523
99202-4635
(16) 9208-4635
China CN 18911111111
189 1111 1111
189-1111-1111
0086-18911111111
+86-18911111111
86-18911111111
0086 18911111111
+86 18911111111
86 18911111111
0086 189-1111-1111
+86 189-1111-1111
86 189-1111-1111
02011111111
020-11111111
020 11111111
020 1111 1111
020-1111-1111
0086 020 82803159
0086-020-82803159
+86 20 61302222-8866
+86 20 6130-2222-8866
+86 10 59081185
Czech Republic CZ 00420123456789
00420 123456789
00420 123 456 789
00 420 123 456 789
+420123456789
+420 123456789
+420 123 456 789
123456789
123 456 789
420123456789
420 123456789
420 123 456 789
00421123456789
00421 123456789
00421 123 456 789
00 421 123 456 789
+421123456789
+421 123456789
+421 123 456 789
Denmark DK
France FR 0644444444
06 44 44 44 44
06-44-44-44-44
06.44.44.44.44
+33644444444
+336.44.44.44.44
+33 6.44.44.44.44
0033644444444
00336.44.44.44.44
0033 6.44.44.44.44
+33(0)644444444
+33 (0) 644444444
06 44.44-44.44
06 44 44-4444
06444444444444
6644444444
06 44.44-44.44
+33 (0) 644444444
(0)644444444
+33-(0)-644444444
+33 (0)-644444444
+33-(0) 644444444
06.44.44.44.44.
Germany DE +49(89)123456
089-1234567
0891234567
0049-89-123456
089 123456-78
India IN 9999114011
+919911112341
+91 9415007327
03598245785
+911204312280
1302231221
Morocco MA 0644444444
0610245896
0630548564
06 44 44 44 44
06-44-44-44-44
06.44.44.44.44
06 44.44-44.44
0528254856
0535484541
05 28 44 44 44
05-28-44.44.44
05.28.44.44.44
05 28.44-44.44
+212644444444
+2126.44.44.44.44
+212 6.44.44.44.44
00212644444444
002126.44.44.44.44
00212 6.44.44.44.44
+212(0)644444444
+212 (0) 644444444
0625468961
0512548632
0542564896
06444444444444
6644444444
06 44.44-44.44
+212 (0) 644444444
(0)644444444
Netherlands NL 0101234567
010-1234567
010 - 123 45 67
010 1234 567
06-12345678
06 123 456 78
0111-123456
0111 123456
+31101234567
0031101234567
+31(0) 10123 4567
+3110-1234567
003110 1234567
+316 123 456 78
+31(0)6 123 45678
+31111-123456
0031111-123456
06-1234-5678
06 123456789
06 1234567
+31(06) 123 45678
1234567
Pakistan PK 03336527366
Romania RO +40213.564.864
+40213 564 864
0213-564-864
0213564864
0313564864
0720512346
0730512346
0740512346
0750512346
+40750512346
+40750.512.346
0760512346
0770512346
0780512346
40213-564-864
0213/564/864
0413564864
0790512346
Russia RU +7(911)976-91-04
Slovakia SK 00421123456789
00421 123456789
00421 123 456 789
00 421 123 456 789
+421123456789
+421 123456789
+421 123 456 789
123456789
123 456 789
421123456789
421 123456789
421 123 456 789
00420123456789
00420 123456789
00420 123 456 789
00 420 123 456 789
+420123456789
+420 123456789
+420 123 456 789
Spain ES
Thailand TH
United Kingdom GB 01611234567
0161 123 4567
(0161) 123 4567
0161-123-4567
+44 161 123 4567
+441611234567
+44(0)161234567
00 44 161 1234567
(011) 44 161 234567
0161-158-5587
0161 123 4567 ext. 123
01611234567x123
+44161234567x123
+44 (0) 161 1234567 ext 123
012345678900
1611234567
012345678
123 4567
061 123 4567
Venezuela VE

Using with JavaScript module


// You might need to change the importing path
import phone from 'formvalidation/validators/phone';

const result = phone().validate({
    value: ...,
    options: {
        // Can be a string or a function returns a string
        country: ...,
        message: ...,
    },
});
/*
result is an object of
{
    valid: true or false,
    message: The error message
}
*/

Basic Example

You can click on sample from the table above to see if it's a valid or invalid phone number.

Module Example

The following snippet shows how to use the phone validator with JavaScript module:


// You might need to change the importing path
import phone from 'formvalidation/validators/phone';

const res1 = phone().validate({
    value: '246.555.8888',
    options: {
        country: 'US',
        message: 'The value is not a valid phone number',
    },
});
// res1.valid === true

const res2 = phone().validate({
    value: '(+55) 15 3702-7523',
    options: {
        country: 'BR',
        message: 'The value is not a valid phone number',
    },
});
// res2.valid === true

Related validators

The following validators are similar to this one and might be useful to you.

Name Description
zipCode Validate a zip code