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.
Solved this by replacing the value with the validator SubmitHandler event: https://api.jquery.com/submit/