Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

295
Vistas
How to get country value from intl-tel-input?

so im new on javascript. I want to create form there is two field, phone number and country. And i want to seperate them on my database. I wonder how can i get country value from intl-tel-input ( https://github.com/jackocnr/intl-tel-input ). for example HTML

                      <form>
                        <label>Phone Number</label>
                        <!-- using intl-tel-input -->
                        <input type="tel" name="phone">

                        <label>Country</label>
                        <!-- how can i get country value automatically here from phone number field? -->
                        <input type="text" name="country">
                      </form>

Anyone can help me figure this out? thanks in advance.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

<!-- REQUIRED CDN  -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/intlTelInput.min.js"
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/css/intlTelInput.min.css"
crossorigin="anonymous" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.js" crossorigin="anonymous"></script>

<input name="phone" type="text" class="form-control mb-2 inptFielsd" id="phone"
placeholder="Phone Number" />

<label>Country</label>
<input id="country" type="text" name="country">

<script>
    var input = document.querySelector("#phone");
    window.intlTelInput(input, {
        separateDialCode: true,
        customPlaceholder: function (
            selectedCountryPlaceholder,
            selectedCountryData
        ) {
            return "e.g. " + selectedCountryPlaceholder;
        },
    });
  
    var iti = window.intlTelInputGlobals.getInstance(input);

    input.addEventListener('input', function() { 
      var countryName = iti.getSelectedCountryData().name;
      document.getElementById('country').value = countryName;
    });
</script>

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda