Skip to main content

Phone Input

The Phone Input component can be used to capture and validate phone number from the user.

Schema

[
{
"name": "phone_number",
"meta": {
"displayName": "Phone Number",
"description": "Phone Number Input Field",
"displayType": "phone",
"placeholder": "Enter Phone Number",
"validation": {
"required": true,
"matchIsValidTel": true // false to disable
},
"readOnly": false,
"htmlProps": {
"disabled": false,
"defaultCountry": "US", // US, CA, MX, IN, ...
"onlyCountries": ["US", "CA", "IN"],
"continents": ["NA", "SA", "AS"], // EU, NA, SA, AS, OC, AF
"allowDynamic": true,
"preferredCountries": ["US", "IN"]
},
"value": "+12124567890"
}
}
]

Example

Phone Number Input Field

Form Data:
{}

Field properties

NameDescriptionType
defaultCountrySets the selected country on component mount. Is Mandatory Fieldstring
excludedCountriesCountry codes to be excluded of the list of countries.string[]
onlyCountriesCountry codes to be included in the list of countries.string[]
preferredCountriesCountry codes to be highlighted to the top of the list of countries.string[]
continentsContinent codes to include a group of countries.string[]
displayTypeThe type of control, which defines how the input is presented (e.g., "phone").string
displayNameThe display name of the control, shown as a label or header.string
placeholderThe placeholder text for the input field, guiding the user on what to enter.string
requiredA boolean indicating if the control is required.boolean
matchIsValidTelA boolean indicating if phone number validation is required when the field is out of focusboolean
disabledA boolean indicating if the control is disabled.boolean
readOnlyA boolean indicating if the control is readonly.boolean

Continent Codes Supported

CodesContinents
AFAfrica
ASAsia
EUEurope
NANorth America
OCOceania
SASouth America

Countries Codes Supported :

To view all the country codes, visit the ISO-3166 Country Codes page.

Here are some JSON samples for different configurations of the file upload control:

Sample 1: Basic Phone Input

{
"name": "phone_number",
"meta": {
"displayName": "Phone Number",
"description": "Phone Number Input Field",
"displayType": "phone",
"placeholder": "Enter Phone Number",
"validation": {
"required": true,
"matchIsValidTel": false
},
"readOnly": false,
"htmlProps": {
"disabled": false,
"defaultCountry": "US" // US, CA, MX, IN, ...
},
"value": "+12124567890"
}
}

Sample 2: Phone Input with onlyCountries and continents

{
"name": "phone_number",
"meta": {
"displayName": "Phone Number",
"description": "Phone Number Input Field",
"displayType": "phone",
"placeholder": "Enter Phone Number",
"validation": {
"required": true,
"matchIsValidTel": true // false to disable
},
"readOnly": false,
"htmlProps": {
"disabled": false,
"defaultCountry": "US", // US, CA, MX, IN, ...
"onlyCountries": ["US", "CA", "IN"], // Always include defaultCountry in onlyCountries field
"continents": ["NA", "SA", "AS"], // Always include all continents that contain all countries from defaultCountry and onlyCountries field
"preferredCountries": ["US", "IN"] // Always keep preferredCountries from onlyCountries field
},
"value": "+12124567890"
}
}

Sample 2: Phone Input with excludedCountries and continents

{
"name": "phone_number",
"meta": {
"displayName": "Phone Number",
"description": "Phone Number Input Field",
"displayType": "phone",
"placeholder": "Enter Phone Number",
"validation": {
"required": true,
"matchIsValidTel": true
},
"readOnly": false,
"htmlProps": {
"disabled": false,
"defaultCountry": "IN",
"excludedCountries": ["US", "CA"], // Never include defaultCountry & onlyCountries values in excludedCountries field
"continents": ["NA", "SA", "AS"], // Always include all continents that contain all countries from defaultCountry
"preferredCountries": ["IN"] // Always keep preferredCountries from onlyCountries field
},
"value": "+917892345678"
}
}

Field Properties - Validation Details

The validation settings within the Textarea component are crucial for ensuring that user input meets specific requirements. Here’s a breakdown of the available validation properties:

PropertyDescription
requiredBoolean value that specifies whether entering data into the field is mandatory.
minLengthSpecifies the minimum number of characters allowed in the input.
maxLengthSpecifies the maximum number of characters allowed in the input.
minSpecifies the minimum value allowed for number inputs, with support for dynamic values.
maxSpecifies the maximum value allowed for number inputs, also supporting dynamic conditions.
patternA regex pattern that the input must match to be considered valid.
validateA function for custom validation logic, which can return a boolean or an error message.
matchIsValidTelBoolean value that specifies whether or not to validate the input as a phone number.

Example Usage of Validation Properties

{
"name": "phone_number",
"meta": {
"displayName": "Phone Number",
"description": "Phone Number Input Field",
"displayType": "phone",
"placeholder": "Enter Phone Number",

"validation": {
"required": true,
"minLength": 10,
"maxLength": 300,
"min": 10,
"max": 300,
"matchIsValidTel": true
"pattern": "/^[a-zA-Z0-9 .,'-]+$/",
},
"readOnly": false,
"htmlProps": {
"disabled": false,
"defaultCountry": "IN",
"excludedCountries": ["US", "CA"], // Never include defaultCountry & onlyCountries values in excludedCountries field
"continents": ["NA", "SA", "AS"], // Always include all continents that contain all countries from defaultCountry
"preferredCountries": ["IN"] // Always keep preferredCountries from onlyCountries field
},
"value": "+917892345678"
}
}