Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

284
Views
Conditionally manage intlTelInput dial-code in javascript

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,
    });              
}
});
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!