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

363
Vistas
Intl-tel-input library keeps throwing error on multiple elements

I'm using the Intl-tel-input library to mask my phone number fields, I'm using multiple elements, however, only the first one is working, the 2nd and the 3rd are throwing Uncaught TypeError: Cannot read properties of null (reading 'getAttribute') error.

JS:

const account_phone = document.querySelector('#account-phone');
const delivery_phone = document.querySelector('#delivery-phone');
const signup_phone = document.querySelector('#signup-phone');

const account_iti = intlTelInput(account_phone, {
    utilsScript: 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.min.js',
});

const delivery_iti = intlTelInput(delivery_phone, {
    utilsScript: 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.min.js',
});

const signup_iti = intlTelInput(signup_phone, {
    utilsScript: 'https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.8/js/utils.min.js',
});

HTML:

1)
<input type="text" name="phone" id="account-phone" />
2)
<input type="text" name="user_phone" id="signup-phone" />
3)
<input type="text" name="phone" id="delivery-phone" />

Notes:

  • Each input is on a different page, when I tried this specific code in the same page, it worked
  • Once I comment out any 2 of them, the 3rd one is working

What could the issue be?

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

0

It's because the browser was throwing an error since the variables were not really there, worked after I used a conditional. I hate vanilla JS.

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