jackocnr / intl-tel-input

A JavaScript plugin for entering and validating international telephone numbers. React and Vue components also included.
https://intl-tel-input.com
MIT License
7.64k stars 1.95k forks source link

Have getNumber problem using Ajax , please help ! #941

Closed gsmdenis closed 5 years ago

gsmdenis commented 5 years ago

Have getNumber problem using Ajax , please help ! this is popup window

https://codepen.io/gsmdenis/pen/GVqJNY

jackocnr commented 5 years ago

Seems to be working fine to me. If I load that codepen, and type a valid number then it appears in the output box. What is the problem you're having?

gsmdenis commented 5 years ago

hi, jack , thanks for your reply , the case i can not get the hiddenInput when submit, i know output working fine, thats just for test

jackocnr commented 5 years ago

You've set the hiddenInput to "getNumber" which doesn't make sense. Did you read the readme documentation for the hiddenInput option? You want to set it to the name that you want to give to the generated hidden input.

gsmdenis commented 5 years ago

yes, i read , but get a little bit confuse, that's why ask you for help , please guide me how make it works , thanks in advance

jackocnr commented 5 years ago

Your main input is called "mobile", so I recommend you set hiddenInput to "mobile_full". Then look out for a POST parameter on your server with that name.

I can see the hidden input is being created correctly, so I don't think this is a problem with the plugin - I'm guessing it's an issue on your server. I can't help with server issues, so I'd recommend asking on StackOverflow.

gsmdenis commented 5 years ago

i test at localhost , i try this at different pages, another please was not a popup window, Request method:POST working fine, but this code, no matter what i tried, can not get ""Country Code" (+xx), i also test with mobile_full seems same issue! thanks for your reply !

jackocnr commented 5 years ago

Ah well if you're doing an Ajax request then you don't need the hiddenInput option. Instead, in your submit handler, you just get the full number using iti.getNumber().

gsmdenis commented 5 years ago

Thanks for your reply, Seems i do like this still not work :

jackocnr commented 5 years ago

I'm sorry but I think you're struggling with the basics of JavaScript and that's outside the scope of the support I can provide. I recommend you ask on StackOverflow.