We have a phone field in our form. It’s using the International format which essentially allows the inputter to type any number of digits and symbols into the phone field.
Above method is great, but does not guarantee we’ll capture the inputter’s country code (i.e., calling code).
So, does anyone know how to best capture the country code in the frontend/backend based on the input phone number? We have installed and tested many plugins, but they all have one or several drawbacks.
Any suggestions (e.g., code snippet, filter, plugin) that will allow us to capture the country code?
For now, our best solution is to add a “City, State, and Country” (short address) field in our form to help out.
We had previously tested the plugins you shared, and none seemed to work well at first.
So we decided to give the plugin, Smart Phone Field for Gravity Forms, another run (with a few adjustments and lots of testing performed) and now works beautifully.
In order for the plugin to function properly, these are the plugin adjustments that users need to make after activation:
(3) When testing the plugin (frontend), and you purposely enter the wrong number for a given country, the form will display a message that says: “Invalie number” Obviously, this is a typo (should say “Invalid number”) and can be corrected as follows:
(a) Go to: /public_html/wp-content/plugins/smart-phone-field-for-gravity-forms/frontend/js/spf_main.js
(b) In edit mode, search for the keywords or term: “Invalie number” in the above file and change it to “Invalid number”
Voila!
You got yourself an amazing new Phone field feature integrated into your form.