WPIntell

Source evidence

Submitting letters

Smart phone field for Gravity Forms · support · 2024-05-21T09:39:00+00:00

mixedsentiment
mediumseverity
0.78relevance
5replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

8 / 36 rows with source links

22.2% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

28 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
ancaa resolved
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()); } }); } }); add_filter('gform_field_validation', function($result, $value, $form, $field) { // Check if the field is the phone field you want to validate if ($field->type == 'phone') { $lang = get_locale(); $phone_message_form = "Please enter a valid phone number."; $messages = [ "de_DE" => "Bitte geben Sie eine gültige Telefonnummer ein.", "es_ES" => "Por favor, introduzca un número de teléfono válido.", "nl_NL" => "Voer een geldig telefoonnummer in.", "en_US" => "Please enter a valid phone number." ]; if (array_key_exists($lang, $messages)) { $phone_message_form = $messages[$lang]; } // Allow letters and digits in the phone field if (!preg_match('/^[a-zA-Z0-9\s\+\-\(\)\[\]\/]*$/', $value)) { $result['is_valid'] = false; $result['message'] = $phone_message_form; } } return $result; }, 10, 4); This problem is for auto flag countries Hi, @ancaa , Thanks for your support threads. Gravity forms allow letters in the phone field. For this reason, it accepts text/letters. I am checking this issue. I will fix it with javascript and update here soon. Thanks for your patience. This reply was modified 2 years ago by Kaisar Ahmmed . Hello, The validation process functions correctly; however, there’s an issue with the auto flag and dial number disappearing upon form submission containing letters. Numbers alone submit correctly, same for numbers and letters. Thank you Hi @ancaa Please update the plugin. Letter submitting issue is fixed. Thanks

Comments

5 shown
ancaa 2024-05-21T10:40:00+00:00

add_filter('gform_field_validation', function($result, $value, $form, $field) { // Check if the field is the phone field you want to validate if ($field->type == 'phone') { $lang = get_locale(); $phone_message_form = "Please enter a valid phone number."; $messages = [ "de_DE" => "Bitte geben Sie eine gültige Telefonnummer ein.", "es_ES" => "Por favor, introduzca un número de teléfono válido.", "nl_NL" => "Voer een geldig telefoonnummer in.", "en_US" => "Please enter a valid phone number." ]; if (array_key_exists($lang, $messages)) { $phone_message_form = $messages[$lang]; } // Allow letters and digits in the phone field if (!preg_match('/^[a-zA-Z0-9\s\+\-\(\)\[\]\/]*$/', $value)) { $result['is_valid'] = false; $result['message'] = $phone_message_form; } } return $result; }, 10, 4);

ancaa 2024-05-21T10:58:00+00:00

This problem is for auto flag countries

Kaisar Ahmmed 2024-05-21T11:30:00+00:00

Hi, @ancaa , Thanks for your support threads. Gravity forms allow letters in the phone field. For this reason, it accepts text/letters. I am checking this issue. I will fix it with javascript and update here soon. Thanks for your patience. This reply was modified 2 years ago by Kaisar Ahmmed .

ancaa 2024-05-21T12:19:00+00:00

Hello, The validation process functions correctly; however, there’s an issue with the auto flag and dial number disappearing upon form submission containing letters. Numbers alone submit correctly, same for numbers and letters. Thank you

Kaisar Ahmmed 2024-08-11T10:46:00+00:00

Hi @ancaa Please update the plugin. Letter submitting issue is fixed. Thanks