Fields

Phone

Phone is the phone number field. It can render as a basic tel input or use the phone-country module for country selection and validation.

Use this page to preserve the input attributes and, when the country setting is enabled, the hidden country input that keeps the submit payload aligned.

Preview

Attributes

Phone fields can include both a visible tel input and, when country selection is enabled, a hidden country input.

Field

AttributePurposeImportance
data-formie-field-handleStable field identity used by validation and error renderingRequired

Field input

AttributePurposeImportance
input[type="tel"][data-formie-phone-input]Visible phone input selectorRequired for phone-country enhancement
data-formie-inputGeneric Formie input marker included in normal outputRecommended
data-formie-input-idStable visible-input identityRecommended

Country input

AttributePurposeImportance
input[data-formie-phone-country-input]Country-code storage input kept in sync by the moduleRequired when country setting is enabled

Styling classes

These classes are for presentation only. They are not behavior requirements:

Field input

ClassDescription
formie-inputShared tel-input styling and focus treatment
formie-input-errorError-state styling class

Behavior

The phone-country module:

  • mounts intl-tel-input onto the visible tel input
  • keeps the hidden country input synchronized with the selected ISO country code
  • validates international numbers through the form validator layer

Events

Phone-country-enhanced fields emit field events in addition to the broader events documented on JavaScript events.

The formie:field:phone-country:before-init event

Triggered before intl-tel-input is mounted. Use this to change the plugin options before initialization.

js
document.addEventListener('formie:field:phone-country:before-init', (event) => {
  // Limit the picker to the countries supported by this form.
  event.detail.options.onlyCountries = ['us', 'ca', 'gb'];
});

The formie:field:phone-country:init event

Triggered after the phone input, country synchronization, and validator wiring are ready.

js
document.addEventListener('formie:field:phone-country:init', (event) => {
  const { phoneCountry, validator } = event.detail;

  // Only proceed when the phone input has been enhanced successfully.
  if (!(phoneCountry instanceof HTMLInputElement)) {
    return;
  }

  const selectedCountry = validator.getSelectedCountryData()?.iso2;

  if (!selectedCountry) {
    return;
  }

  // Expose the active country code for custom labels or analytics hooks.
  phoneCountry.closest('[data-formie-field]')?.setAttribute('data-phone-country', selectedCountry.toUpperCase());
});
Last updated: May 6, 2026, 3:46 PM