Funnelish™ Community

Feature Request: Enforce Country Code and format

I need a code to add a feature to my funnels. I would like to set a prefix to the phone number field. For example “+57” in order to the customer don’t write the country code. This prefix can not to be delete by the customer.
An additional wanted feature is the phone number field only accept numeric characters and having a fixed long.

1 Like

Hello @idelasotta ,

First of all, extremely sorry for the long delay on this, this thread was buried under our recent posts. and thank you for reminding us through the direct chat.

Here is the code you can use to enforce a phone number prefix:

const PHONE_PREFIX = "+56";

    if (!i.value) i.value = PHONE_PREFIX;
    if (!i.value.startsWith(PHONE_PREFIX)) {
        i.value = PHONE_PREFIX + i.value.replace('+','');
    i.addEventListener('input', (e)=>{
        if (!i.value.startsWith(PHONE_PREFIX) && i.dataset.oldPhone && i.dataset.oldPhone.startsWith(PHONE_PREFIX)) {
            i.value = i.dataset.oldPhone;
        i.dataset.oldPhone = i.value;

How it works?

  1. Copy the code above as it is into your page Custom Codes > Body JS.

  2. You can modify the phone prefix on the first line if needed ‘PHONE_PREFIX"+56"

  3. Save changes and take it for a spin, do let us know if it needs any improvement.