cldb2016 Posted January 24, 2016 Report Share Posted January 24, 2016 I created a submission form datapage where a user enters there telephone number in the following format +17035551212 (+ / country code / area code / seven digit number). I am trying to find a java script or some other way to remove the first two characters of this string and insert it into another field in the same table. The resulting number should be 7035551212 Any help would be appreciated. I am not a java expert, but I know enough to modify and insert basic scripts. Quote Link to comment Share on other sites More sharing options...
cldb2016 Posted January 25, 2016 Author Report Share Posted January 25, 2016 I managed to come up with this script, but it does not work. Any suggestions would be helpful. I also added removing the last two characters of the number to the script. Fields "mobilenumber" is in the format of +17035551212, "mobilenumberten" 7035551212, and "mobilenumbereight" 70355512. <SCRIPT LANGUAGE="JavaScript"> function rewriteMobileNumber() { var mobilenumber,mobilenumberten,mobilenumbereight; mobilenumber = document.getElementById("mobilenumber").value; mobilenumberten = mobilenumber.substring(2); document.getElementById("mobilenumberten").value = mobilenumberten; } document.getElementById("caspioform").onsubmit=rewriteMobileNumber; </SCRIPT> Quote Link to comment Share on other sites More sharing options...
Jan Posted January 25, 2016 Report Share Posted January 25, 2016 Hello cldb2016, Welcome to Caspio forum!If I understand correctly, you can find instructions how to work with fields on DataPages in the article. I have edited your code a bit: <SCRIPT LANGUAGE="JavaScript"> function rewriteMobileNumber() { var mobilenumber = document.getElementById("InsertRecordmobilenumber").value; var mobilenumberten = mobilenumber.substring(2); document.getElementById("InsertRecordmobilenumbereight").value = mobilenumberten; } document.getElementById("caspioform").onsubmit=rewriteMobileNumber; </SCRIPT> I hope, it works now. Quote Link to comment Share on other sites More sharing options...
cldb2016 Posted January 25, 2016 Author Report Share Posted January 25, 2016 It works. Thank you for the information and the edit. Quote Link to comment Share on other sites More sharing options...
Kurumi Posted December 24, 2021 Report Share Posted December 24, 2021 Hi! Just an update on this, Caspio has a new Tech Tip called: Format Phone Number in DataPages. You may visit it here: https://howto.caspio.com/tech-tips-and-articles/advanced-customizations/format-phone-number-in-datapages/ Quote Link to comment Share on other sites More sharing options...
Kurumi Posted July 15, 2022 Report Share Posted July 15, 2022 Hi All - In relation to Caspio's new feature of Worldwide SMS Notifications, if you would like your input phone number fields to be automatically formatted - you can use the International Telephone Input plugin. This JavaScript plugin is used for entering and validating international telephone numbers. It adds a flag dropdown to any input, detects the user's country, displays a relevant placeholder, and provides formatting/validation methods. To know more of the customization, you can check this link: https://github.com/jackocnr/intl-tel-input Here's a sample result in DataPage: After submission in table: Related articles: https://howto.caspio.com/notifications/sms-notifications/configuring-the-sms-enabled-countries/https://howto.caspio.com/release-notes/caspio-32-0/ Hope it helps! 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.