Submitting letters
-
Hello,
When I submit letters instead of numbers the country code and flag dissapears. How can I manage this situation in order to keep this two when submitting? The error is showing correct message, the letters remain in the field but those two dissapears. I used this code but no success
$(document).ready(function() { var phoneField = $('.ginput_container_phone input'); if(phoneField.length) { var originalCountryCode = ''; var originalFlagClass = ''; phoneField.on('input', function() { var value = phoneField.val(); var countryCodeMatch = value.match(/^\+\d+/); var countryCode = countryCodeMatch ? countryCodeMatch[0] : ''; // Save the country code and flag class if it exists if (countryCode) { originalCountryCode = countryCode; originalFlagClass = $('.iti__selected-flag').attr('class'); } // Remove the country code from the value to process the rest of the input var numberPart = value.replace(/^\+\d+/, ''); // Set the input value to the original country code plus the rest of the input phoneField.val((originalCountryCode ? originalCountryCode : '') + numberPart); // Restore the flag and dial code elements if they are not visible if (!$('.iti__selected-flag').hasClass('iti__flag') || !$('.iti__selected-dial-code').text()) { $('.iti__selected-flag').attr('class', originalFlagClass); $('.iti__selected-dial-code').text(originalCountryCode); } // Re-trigger the plugin's validation or refresh method, if available if (phoneField.intlTelInput) { phoneField.intlTelInput("setNumber", phoneField.val()); } }); } });
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- You must be logged in to reply to this topic.