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

326
Visualizações
Using jQuery Validation with intl phone input

I'm using the plugin for phone number checking intlTelInput (Github) and created a custom validation method in jQuery validator as:

// Valid phone using the tel input check
$.validator.addMethod( "checkNumber", function( value, element, param ) {
    // TODO: Change to API check
        return (phoneInput.isValidNumber());

}, "Phone number is incorrect or invalid." );

This work as validation. It will default to an error when the number has the improper format but how do I use save the intl format in the form value? The puporse of the plugin is to save the format in the international format such as: +12015551256

Tutorial here: https://www.twilio.com/blog/international-phone-number-input-html-javascript

The plugin will correctly identify a number such as (201) 555-1256 as valid and so does jQuery Validation with the above code in my validator, the issue is that after posting the form it will actually be saved as shown in the form and not the formatted intl format the plugin is supposed to use.

I think I need to pass the phoneInput to the form after validation but can't seem to make it work.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Solved this by replacing the value with the validator SubmitHandler event: https://api.jquery.com/submit/

https://jqueryvalidation.org/validate/

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