-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uncaught Error: No country data for 'undefined #1525
Comments
Yeah it would be helpful to have a demo to play with, with clear instructions on how to reproduce the error. If it helps you can fork this codepen. |
Here it is: This demo uses api token for ipinfo that do not allow this domain. Therefore the auto prefix/country by IP will not work. Furthermore, right after the submission when the form is invalidated (server side - no submission yet), the error "Uncaught Error: No country data for 'undefined" appears. At that moment, the field is not more able to be validated client side. Now, I may select a country, change a bit the value of the phone input (with an invalid still phone), re-submit. Let me know if you need more info. |
The first problem is with your The next problem is with validation. You say that on submit, "It validates via AJAX", and yet when I tried it, it did a full page load, which is different to using Ajax! So firstly, I would encourage you to do client-side validation first, using the |
Btw I've just tweaked the |
My bad regarding the AJAX... I forgot to enable AJAX for that form. It is enabled now. But, anyway the issues are similar and I am proceeding with it. Thanks |
It looks like the geo lookup is working now, but then you're passing Additionally, if you update to the latest version, it will handle geo lookup failures much better. |
I have fixed most of my issues on my localhost. This helps in general, however I now realise that this might not be the most optimal scenario. For example, the user may insert/type his phone number and forget to select the right country. It is possible that the phone will still be valid, but with the wrong prefix. So, is it possible to have no country selected if the auto (by IP) isn't working, so any phone number in the field will not be valid, enforcing the user to at least deal with the Flags dropdown. (If a user in this case select a wrong flag and his phone will still be valid it is something we can not deal anyway). |
I'm glad things are working better now.
Yes this is not ideal, but I think it's also an edge case - that (1) the user autofills their phone number, and (2) it doesn't include an international dial code, and (3) the number also happens to be valid in whichever country is first in the list, and (4) the user doesn't notice that the wrong flag is displayed. I think that combination of events is very unlikely to happen. Whereas if we start things off with a blank flag, it makes it completely unclear what the dropdown is even for. In my opinion, starting off with the first country in the list is a much better user experience, as it makes it clear what the dropdown is for and what the user has to do. It's a trade-off, but this is my opinion for now. I'll close this issue for now, but do let me know if you have any more thoughts. |
Hello @jackocnr My managers are not happy with this, although I have explained them everything that is involved. They requested improvements with the goal of ensuring that users cannot submit a phone number with the incorrect prefix. Revisiting our earlier discussion, I'm bringing back the idea of implementing an empty country/flag option for cases where the auto-IP detection fails or if we opt to remove the auto-IP feature entirely. As an alternative consideration, or perhaps a fallback solution if the first option proves unfeasible, I'm also reevaluating the possibility of setting the USA as the default flag. This approach hinges on the assumption that the unique format of USA phone numbers might increase the rate of invalidation for incorrectly entered numbers from users outside the USA, thereby enhancing our system's accuracy. Any thoughts? |
Hmm... it also looks like it doesn't respect the initialCountry option. Options: |
I forked the demo you shared earlier, and it appears that the 'initialCountry' feature isn't functioning there either. Check here: https://codepen.io/jmbeat/pen/eYXogaY |
Update: it looks like it requires the country code in lowercase. |
The As for the empty flag situation, I appreciate your input, and I agree it may not be an edge case after all - there may be lots of cases where neighbouring countries share the same valid phone patterns, and then I think we should add a new I also think we should add a note to the What do you think? |
Sounds good.
Regarding the empty grey square - my initial solution was to not have a default country somehow if the auto wasn't working. I was getting that grey square. That solution had my previous issues though, but especially for the grey square I found a flag like icon - not one of a country - and I used that through css. |
Can you share your generic flag icon? |
I used this one: https://www.svgrepo.com/svg/508681/flag-ww |
Out of interest, can I ask why you still use the preferredCountries option instead of the new country search? |
I switched to the country Search, but the managers didn't like it and requested to use the preferred countries (around 6-7 countries which are the target audience the the majority of the leads comes from). |
managers aye 🙄 |
I just added a |
I've added a new globe icon in v19.5.0 - let me know what you think. |
Thanks for these updates. I have been busy with other tasks, which I need to complete before March 7, when I will be travelling abroad. I am going to integrate the latest version and test the new features, but I am not sure about the when. |
No worries. I'll close this for now then, but do have a look when you can 👍 |
Getting "Uncaught Error: No country data for 'undefined'" under some specific conditions.
I am entering an invalid phone value without selecting a country (doing so with Opera browser, which blocks the ipinfo by default, so there is no auto-country selection) -> Submitting the form -> It validates via AJAX and returns that the submission is invalid for the field.
At that point, if I edit the phone number in the field, the error I reported is thrown. It also stops any further validation for the phone.
However, if I resubmit the form and fails the validation again, after that point, the previous error is not occurring again and client side validations work.
Well, this is a WP site with gravity forms and it's an implementation with a gravity forms plugin. The plugin was using an older version of the ITI plugin, which I updated it to the latest version because of some issues in mobile devices in creating the countries list.
I am going to create an online demo to showcase the issue and will come back to share the link.
Initialisation options
utilsScript
useFullscreenPopup: false
countrySearch: false
showSelectedDialCode: true
preferredCountries: yes
The text was updated successfully, but these errors were encountered: