Skip to main content

Enable Phone Number Validation for US Only

This will setup an input box that when people type their phone number it will be formatted as (###) ###-####

Updated over 5 years ago

The phone number and mobile number fields are designed to handle both US and Non-US phone numbers.  If you would like to restrict it to be US only, please add the following code to your layouts (or a javascript file in your layouts).

$("[data-validate*='tel']").each(function () {
     var inputElement = document.getElementById($(this)[0].id);
     inputElement.addEventListener('keydown', enforceFormat);
     inputElement.addEventListener('keyup', formatToPhone);
});
Did this answer your question?