LWSChad Posted August 13, 2014 Report Share Posted August 13, 2014 Hello; I use the JavaScript Here to format phone numbers. <SCRIPT LANGUAGE="JavaScript"> function f_a(v_id) { return document.getElementById(v_id); } f_a('InsertRecordPhone').maxLength = 14; f_a('InsertRecordPhone').onkeyup = function(v_e) { v_e = v_e || window.event; if (v_e.keyCode >= 65 && v_e.keyCode <= 90){ this.value = this.value.substr(0, this.value.length - 1); return false; }else if (v_e.keyCode >= 37 && v_e.keyCode <= 40){ return true; } var v_value =(this.value.replace(/[^\d]/g, '')); if (v_value.length==7) { this.value = (v_value.substring(0,3) + "-" + v_value.substring(3,7));} else if(v_value.length==10){ this.value = ("(" + v_value.substring(0,3) + ") " + v_value.substring(3,6) + "-" + v_value.substring(6,10)); }; } </SCRIPT> Does anybody know how to get a search field to behave the same way? I've tried InsertRecordPhone, SearchPhone, EditRecordPhone, Search, and Value1_1(It's actual id). Thanks Quote Link to comment Share on other sites More sharing options...
Jan Posted August 14, 2014 Report Share Posted August 14, 2014 Hello EIQ, I tried Value2_1 (my field is the second in the first section) and the script works. It works rather slowly, but it works the same on the Submission form. Could you give the URL to your DataPage? By the way, there is the article about names of variables. Quote Link to comment Share on other sites More sharing options...
LWSChad Posted August 14, 2014 Author Report Share Posted August 14, 2014 I figured it out. It needs to be the only DataPage on the WebPage. Thanks Quote Link to comment Share on other sites More sharing options...
Meekeee Posted October 22, 2021 Report Share Posted October 22, 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/ Hope it helps! Quote Link to comment Share on other sites More sharing options...
Meekeee Posted July 8, 2022 Report Share Posted July 8, 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...
PotatoMato Posted January 21 Report Share Posted January 21 Hi! Just to add, you may also check this article: https://howto.caspio.com/tech-tips-and-articles/enhancing-phone-number-fields-with-formatting-and-validation/ -Potato Quote Link to comment Share on other sites More sharing options...
futurist Posted June 20 Report Share Posted June 20 Hi, you might also want to check this Forum post if you want to enforce the formatting for your phone fields but not make it a require field (allow empty values): 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.