Skip to main content

AddressfinderPhone.Phone.Widget class

This widget adds phone verification to a simple form field. It will check that the phone number is valid and meets the configured criteria. If unverified, a cross icon and error message (optional) are displayed. A verified phone number is identified with a simple tick icon.

You can choose from block, warn or allow behaviour for each of the three types of phone addresses. These include:

  • nonMobile phone numbers, such as the landline number 09 123 4567.
  • countryNotAllowed. When a phone number might be valid but comes from a country you wish to exclude.
  • Unverified phone number.

More information about how to configure these options and changing the visual styles can be found on the advanced options page. The code examples page demonstrates many of these configuration options.

Constructor

ParameterTypeDescriptionExample
phoneSelectorStringCSS selector for one or more input elements.input.phone_number
licenceKeyStringYour unique licence key.VYT6FHV6TPQEWNBG4K7Q
defaultCountryCodeStringSet the default country codeAU
optionsObjectConfiguration options, see the Options section below.{"rules": {"unverified": "block", "message": "Phone number not verified."}}

Methods

MethodParameterReturn valueDescription
disable()--Disables the Addressfinder phone widget. The verification function will stop working until the widget is re-enabled.
enable()--Re-enables a disabled Addressfinder phone widget.
reactivate()--Executes the verification function on the input value. The Addressfinder phone widget must be enabled.
setDefaultCountryCode()country_code:String-Set the default country to verify phone numbers against after the Addressfinder phone widget has been initialised.

Options

KeyTypeDescriptionDefault
rules.unverified.ruleStringRule for unverified phone addresses: block, warn or allowblock
rules.unverified.messageStringMessage to display to the user when an unverified phone number is detected.Phone number not verified.
rules.countryNotAllowed.ruleStringRule for phone numbers coming from a country you wish to exclude: block, warn or allow.block
rules.countryNotAllowed.messageStringMessage to display to the user when a phone number from a country you wish to exclude is detected.Allowed countries: list of allowed country names.
rules.nonMobile.ruleStringRule for non mobile phone number: block, warn or allow.allow
rules.nonMobile.messageStringMessage to display to the user when a non mobile phone number is detected.-
countrySelectStringCSS selector for the country selector.-
containerDOM elementElement into which the loading indicators and error messages are injected.-
allowedCountryCodesStringList of ALPHA-2 country codes you accept a phone number to come from. Separated by a comma, eg AU,NZ-
timeoutIntegerHow long the API should run before returning an indeterminate connection status.10
countryMappingsObjectAbility to map HTML select values to a ALPHA-2 country code. View a code example.Eg: countryMappings: { "AUS": "AU" }

Events

EventsCallback argumentsDescription
result:verifiedmetadata:ObjectFired when the widget receives a response from the API that aligns with the permissions (allow, warn, block) defined in the widget's rules. e.g. Phone number is verified.
result:not_verifiedmetadata:ObjectFired when the widget receives a response from the API that conflicts with the permissions (allow, warn, block) defined in the widget's rules. e.g. Country not allowed.

Metadata

See phone verification metadata.