Alexray Posted February 7, 2022 Report Share Posted February 7, 2022 Hi there, If you ever faced with the question to format the phone number in Caspio, you probably know that there is a solution to input the phone number in the needed format. But what if you already have a table with phone numbers in the format, like '0123456789', how would you outpu on the Tabular Report in the format '0123-456-789'? That's the question I faced and because of that I decided to write a small JavaScript that I want to share with you hoping it can be useful: <script> document.addEventListener('DataPageReady', function (event) { let columnNumber = 1; let numbers = document.querySelectorAll(`.cbResultSetOddRow > td:nth-child(${columnNumber}), .cbResultSetEvenRow td:nth-child(${columnNumber})`) for (let number of numbers) { let numberText = number.innerText; let cleaned = ('' + numberText).replace(/\D/g, ''); if (cleaned.length == 10) { let match = cleaned.match(/^(\d{3})(\d{3})(\d{4})$/); number.textContent = match[1] + '-' + match[2] + '-' + match[3]; } } }); </script> You can insert the code into HTML block, Header or Footer. Also, on the 3rd line 'let columnNumber = 1;' you need to change that number to the number of the column where you have your phone numbers. If you wish to change it to another format or to use it in another type of report and you do not know how to use that script, please let me know. Quote Link to comment Share on other sites More sharing options...
futurist Posted November 20, 2023 Report Share Posted November 20, 2023 You may refer to this Forum post to validate data entry to make sure that they follow this format: www.websitenamehere.com Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.