Mylene Posted June 14, 2017 Report Share Posted June 14, 2017 Hey everyone! I need to validate phone number which customers enter into the field. It should start from 031 I wonder if someone has a solution for this Thanks! Quote Link to comment Share on other sites More sharing options...
Mathilda Posted June 14, 2017 Report Share Posted June 14, 2017 Hi, You may use the following script: <SCRIPT LANGUAGE="JavaScript"> function tel() { var message = document.getElementById("InsertRecordPhone").value; document.getElementById("InsertRecordPhone").value = (message.replace(/[^\d]/g, '')); var message1 = document.getElementById("InsertRecordPhone").value; var tel =message1.substring(0,3); if (tel!='031'){ alert("Please enter phone number which starts from 031"); return false; } } document.getElementById("caspioform").onsubmit=tel; </SCRIPT> This function will prevent form from submitting if phone starts from other numbers. Don't forget to enter your field name instead of mine. Quote Link to comment Share on other sites More sharing options...
PotatoMato Posted January 21, 2023 Report Share Posted January 21, 2023 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...
NailDyanC Posted January 21, 2023 Report Share Posted January 21, 2023 You can also check this forum post: Quote Link to comment Share on other sites More sharing options...
futurist Posted June 20, 2023 Report Share Posted June 20, 2023 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...
Billp Posted July 25, 2023 Report Share Posted July 25, 2023 On 1/21/2023 at 2:15 AM, PotatoMato said: 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 I am working with the code in the article Potato mentioned. The problem I found was when using it on an update it wipes out the number that was stored in the database. Looking for a solution to that now. Quote Link to comment Share on other sites More sharing options...
speedyturtle Posted September 1, 2023 Report Share Posted September 1, 2023 Hi @Billp, It looks like Caspio has updated the code in that article, maybe it helps to resolve your issue on Update 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.