IsPhoneNumber
→ booleanEvaluates whether a string contains a valid phone number. Returns a boolean suitable for form validation on CloudPages.
Available in:
Email
CloudPage
Automation
Triggered Send
Syntax
Platform.Function.IsPhoneNumber(value)
1 argument
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
value |
string | Yes | String to evaluate as a phone number |
Examples
var phone = Platform.Request.GetFormField("phone");
if (!Platform.Function.IsPhoneNumber(phone)) {
Write('<p class="error">Please enter a valid phone number.</p>');
} else {
Platform.Function.UpsertData("Leads", ["Phone"], [phone], ["Source"], ["web"]);
}
function normalizeContact(raw) {
if (!Platform.Function.IsPhoneNumber(raw.mobile)) {
return { ok: false, msg: "Invalid mobile number" };
}
return { ok: true };
}