Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

374
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda