Closed gsong1205 closed 5 years ago
Hello, I have the same problem, when I try to validate a number with area code 56 for Mexico (+52) I get False, but I expect a True.
isValidNumber: true, el numero es: +52552128** isValidNumber: false, el numero es: +52561746**
I used the following code:
var input = document.querySelector("#fva-mobilephone"),
output = document.querySelector("#fva-landphone");
var iti = window.intlTelInput(input, {
initialCountry: "auto",
preventInvalidNumbers: true,
geoIpLookup: function(success, failure) {
$.get("https://ipinfo.io/json?token=**********", function() {}, "jsonp").always(function(resp) {
var countryCode = (resp && resp.country) ? resp.country : "mx";
success(countryCode);
});
},
nationalMode: false,
autoFormat: true,
utilsScript: "{{ url_for('static',filename='invest/js/utils.js') }}" // just for formatting/placeholders etc
});
// on blur: validate
input.addEventListener('blur', function() {
if (input.value.trim()) {
console.info('isValidNumber: ' + iti.isValidNumber() + ', el numero es: ' + iti.getNumber());
if (iti.isValidNumber()) {
$('#infocorrecta').attr('disabled', false);
} else {
$('#infocorrecta').attr('disabled', true);
sendbtn.disabled = true;
$("#fva-mobilephone").focus();
}
}
});
Some suggestion or help is quite appreciated.
thanks Domingo Tapia
Steps to reproduce
window.intlTelInputUtils.isValidNumber("5614285xxx", "mx")
false
I am wondering why it returned false?Expected behaviour
should return true
Actual behaviour
returned false
Initialisation options