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 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...
NailDyanC Posted January 21 Report Share Posted January 21 You can also check this forum post: 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.