Phone field

A text input pre-configured for phone numbers, telephone keyboard on mobile, optional country-code prefix.

The Phone field is a text input specialised for telephone numbers. It sets

inputMode="tel" for the right mobile keyboard, optionally accepts a country code prefix, and binds to SharePoint's Text column.

Common properties

PropertyDescription
label
string
Visible label.
description
string
Helper text shown under the label.
required
boolean
default: false
Marks the field required.
readOnly
boolean
default: false
Prevents edits but keeps the value submitted.

Type-specific properties

PropertyDescription
placeholder
string
default: +1 (555) 555-1234
Greyed-out hint shown in the empty input.
pattern
string (regex)
Custom validation regex, e.g. ^\+?[0-9 ()-]{7,}$. Overrides the default phone shape.
patternMessage
string
Error message shown when pattern fails (defaults to the browser message).
minLength
number
Smallest accepted character count.
minLengthMessage
string
Error message shown when below minLength.
maxLength
number
Largest accepted character count.
maxLengthMessage
string
Error message shown when above maxLength.

JavaScript recipes

Read the entered number

const phone = String(f365.field('Phone').value ?? '');

Normalise digits as the user types

f365.events.onChange((e) => {
  if (e.fieldKey !== 'Phone') return;
  const digits = String(e.newValue ?? '').replace(/[^0-9+]/g, '');
  if (digits !== e.newValue) f365.field('Phone').value = digits;
});

Custom validation message

f365.events.onValidate((errs) => {
  const phone = String(f365.field('Phone').value ?? '');
  if (phone && !/^\+?[0-9 ()-]{7,}$/.test(phone)) {
    errs.add('Phone', 'Enter a valid phone number (7+ digits).');
  }
});

Block save on a missing area code

f365.events.onBeforeSave(async () => {
  const phone = String(f365.field('Phone').value ?? '');
  if (phone && !phone.startsWith('+')) {
    f365.ui.showToast('Include the country code, e.g. +1.', 'error');
    return false;
  }
  return true;
});

Related articles

  • Text field

    Single-line text input, the foundation field for names, codes, and short free-text.

  • Email field

    A text input with email-address validation and an email-friendly on-screen keyboard on mobile.