Phone number formatting
-
Dear Support Team,
I am using the forminator form to get phone number input from the users. In the Validation of the field, I selected International to include the country code. I am transferring the data to my Google Sheet. The number is stored in the format '+91 91234 56789' in the sheet. How can we trim the spaces in between and remove any special characters, including the plus '+' sign. Actually, I need to send an automated message to the users for confirmation, and API needs the country code, the phone number, and no other characters. Your team shared the following code: <?PHP /** * Plugin Name: Forminator Custom Phone Formatting +91 XXXXX XXXXX. * Description: Forminator Custom Phone Formatting +91 XXXXX XXXXX. */ // Add the custom script to the footer add_action('wp_footer', function () { ?> <script> (function ($) { $(function () { $(document).on("after.load.forminator", function (e, id) { // Phone number formatting logic $('#forminator-field-phone-1').on('input', function () { var number = $(this).val().replace(/[^\d]/g, ''); // Remove non-digit characters // Remove all white spaces number = number.replace(/\s+/g, ''); if (number.length === 10) { // Format as "XXXXXXXXXX" number = number.replace(/(\d{10})/, '$1'); } // Set the formatted number as the input value $(this).val(number); }); }); }); })(window.jQuery); </script> <?PHP }, 21); I entered the above code in a PHP file in mu-plugins folder. But on submission of the form it is still storing the number in the same old format with + sign and spaces. I have checked the file permissions and saved the php file as per the in the following link: https://wpmudev.com/docs/using-wordpress/installing-wordpress-plugins/#installing-mu-plugins Kindly guide what code or settings I need to update.
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘Phone number formatting’ is closed to new replies.