I am using intlTelInput. It's working . I want to manage dial-code based on radio input value. My primary mobile input section
<input type="test" class="phone_number">
$(".phone_number").intlTelInput({
hiddenInput: [],
placeholderNumberType: "MOBILE",
separateDialCode: true,
});
It's working properly . But when I try to fix dial-code based on condition it's not working. Still can be available all value in dropdown
<input type="radio" class="phone" name="phone" value="YES"> Yes
<input type="radio" class="phone" name="phone" value="NO"> No
$(".phone").on('click', function () {
let has_phone = $("input[name='phone']:checked").val();
if(has_phone == 'YES') {
$(".phone_number").intlTelInput({
hiddenInput: [],
onlyCountries: ["uk"],
initialCountry: "UK",
placeholderNumberType: "MOBILE",
separateDialCode: true,
});
}else {
$(".phone_number").intlTelInput({
hiddenInput: [],
placeholderNumberType: "MOBILE",
separateDialCode: true,
});
}
});