Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

323
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!