You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Why does not it contain the "+1" shown as part of the value in the input element?
The problem is vexing because I am using a testing suite in Rails that uses Capybara to find the selectors and get
their values. I don't have access to Javascript in the testing suite.
Expected behaviour
The document query should return the value that includes the country code.
Actual behaviour
The value of the input does not contain the country code
Initialisation options
List any options you're using e.g. loadUtils or onlyCountries
You are doing the wrong method. The correct method is to call the getNumber() function to retrieve the full international number, including the country code.
const inputs = document.querySelectorAll("#phone_numbers__number");
inputs.forEach(function(input){
const iti = intlTelInput(input); // Initialize the intlTelInput on the input field
const number = iti.getNumber(); // Use the getNumber() method to get the full international number
console.log(number); // Output: The full phone number, e.g., "+1 (304) 419-3245"
});
I think you are misunderstanding the issue. I don't have access to Javascript in the testing suite. I used the value method in my example to demonstrate what the testing suite sees. The tests are written in Ruby and uses selectors to get values of the inputs.
Plugin version
24.6.0
Steps to reproduce
As you can see, the value is "+1 (304) 419-3245".
However when I run this in the browser console:
The result is "(304) 419-3245"
Why does not it contain the "+1" shown as part of the value in the input element?
The problem is vexing because I am using a testing suite in Rails that uses Capybara to find the selectors and get
their values. I don't have access to Javascript in the testing suite.
Expected behaviour
The document query should return the value that includes the country code.
Actual behaviour
The value of the input does not contain the country code
Initialisation options
List any options you're using e.g. loadUtils or onlyCountries
The text was updated successfully, but these errors were encountered: