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
| Property | Description |
|---|---|
labelstring | Visible label. |
descriptionstring | Helper text shown under the label. |
requiredboolean default: false | Marks the field required. |
readOnlyboolean default: false | Prevents edits but keeps the value submitted. |
Type-specific properties
| Property | Description |
|---|---|
placeholderstring default: +1 (555) 555-1234 | Greyed-out hint shown in the empty input. |
patternstring (regex) | Custom validation regex, e.g. ^\+?[0-9 ()-]{7,}$. Overrides the default phone shape. |
patternMessagestring | Error message shown when pattern fails (defaults to the browser message). |
minLengthnumber | Smallest accepted character count. |
minLengthMessagestring | Error message shown when below minLength. |
maxLengthnumber | Largest accepted character count. |
maxLengthMessagestring | 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
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.