This discussion originated from a common request to prevent customers from entering incorrect or overly long phone numbers on order forms. While manual JavaScript was the go-to solution in 2023, we have since streamlined this process significantly.
April 2026 Updates: Native Smart Validation
Quick Update: If you’re looking for a way to force the phone number field to exactly 10 digits, you no longer need to use custom workarounds to do this!
Funnelish now features automatic phone number validation built directly into our native checkout forms.
Why the New System is Better
Instead of manually restricting the field to a set number of digits, the phone input now includes a smart country code selector.
- Automatic Detection: It detects the customer’s region based on IP or manual selection.
- Smart Enforcement: It enforces the exact correct character length and standardized format for that specific country.
- Global Compatibility: This is much safer than a strict 10-digit rule, especially if you sell internationally (where numbers can range from 7 to 15 digits).
How to Enable It
You don’t need to write a single line of code. Simply ensure your phone input element is updated to the latest version in the Funnelish editor. For a full breakdown of how this improvement helps your conversion rates and data hygiene, check out our latest guide:
Update: Country Code for Phone Numbers & Latest Funnelish Improvements
Good morning, could you help me with a JavaScript code to limit the number of characters in the phone number box, to prevent the client from leaving wrong data, I tried the following code but it doesn’t work for me.
<script>
function leo($fields) {
$fields['data-name=celular'], ['name=celular'], ['maxlength'] = 10;
return $fields;
}
</script>