How to Add a JetFormBuilder Phone Field with Country Flag and Auto-Detect (No API Key)
How to Add a JetFormBuilder Phone Field with Country Flag and Auto-Detect (No API Key)

UPDATED: 18.08.2025 • If you’re building forms with JetFormBuilder, you’ve probably noticed that the default phone field is pretty basic. Today, I’ll show you how to enhance it with a country flag, automatic dial code, and smart country detection—all without needing a geolocation API key.

Why enhance the JetFormBuilder phone field?

The standard JetFormBuilder Phone field accepts any input, which often leads to invalid or messy numbers. By adding flags and dial codes, you:

  • Make forms more user-friendly and intuitive
  • Reduce typing errors on mobile
  • Automatically normalize numbers for CRM or WooCommerce integration
  • Improve lead quality with consistent E.164 formatting

Features you’ll get

  • Flag + dial code UI powered by intl-tel-input
  • Smart country auto-detection without extra API calls (uses saved value → time zone → browser language → fallback US)
  • Clean submission: numbers stored in +CCXXXXXXXX format
  • Works with any JetFormBuilder form out of the box
  • Lightweight and CDN-optimized

What you need before starting

To use this method, you’ll need:

How to set it up with a snippet plugin

The process is straightforward:

  1. Install and activate your preferred snippet plugin.
  2. Create a new PHP snippet.
  3. Paste the provided code and enable it everywhere on the front-end.
  4. Publish a JetFormBuilder form with a phone field and see the new flag + dial code in action.

How auto-detection works

Instead of relying on a paid API (like Google Maps or IPinfo), the snippet uses a smart detection order:

  1. Previously selected country (saved in localStorage)
  2. Visitor’s time zone → mapped to a country
  3. Browser language and region (e.g. en-GB → UK)
  4. Fallback default (US)

This guarantees a reliable default country flag without slowing down your site.

Customization tips

  • Default country: Change the fallback from US to your main target market.
  • Styling: The snippet respects your form’s placeholder color and width. Add extra CSS if you want custom flag sizes or spacing.
  • Validation: Pair this with JetFormBuilder’s built-in validation to ensure users can’t submit empty numbers.

 

Click to get code

Faqs

1. Do I need an API key for this to work?
No. Unlike many tutorials, this solution doesn’t rely on paid geolocation APIs. It uses browser and system data instead.
2. Will this work with multiple JetFormBuilder forms on the same site?
Yes. Every inside JetFormBuilder automatically gets the flag + dial code UI.
3. What happens if the user changes the country manually?
The choice is remembered locally, so next time they visit, the same country will be preselected.
4. Is this mobile-friendly?
Absolutely. The flag dropdown is optimized for touch devices and looks great in Elementor popups.
5. Will this slow down my site?
No. Assets are served via CDN (jsDelivr), with preloading to minimize delays. Only the phone field loads the script, not every input.