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

327
Vistas
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 Respuestas
Responde la pregunta

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 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