| 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 |
type="tel"
attribute, you should use
type="text"
instead
| Country | Country code |
|---|---|
| United States | US |
| United Arab Emirates | AE |
| Bulgaria | BG |
| Brazil | BR |
| China | CN |
| Czech Republic | CZ |
| Denmark | DK |
| France | FR |
| Germany | DE |
| India | IN |
| Morocco | MA |
| Netherlands | NL |
| Pakistan | PK |
| Romania | RO |
| Russia | RU |
| Slovakia | SK |
| Spain | ES |
| Thailand | TH |
| United Kingdom | GB |
| Venezuela | VE |
// You might need to change the importing path
import
phone
from
'formvalidation/dist/es6/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
}
*/
// You might need to change the importing path
import
phone
from
'formvalidation/dist/es6/validators/phone'
;
const
res1
=
phone
(
)
.
validate
(
{
value
:
''
,
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
country
option isn't passed to the placeholder message