Jump to content

How To Remove First Two Characters Of A Telephone Number


Recommended Posts

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.

Link to comment
Share on other sites

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>
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 5 years later...
  • 6 months later...

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:

image.png

After submission in table:

image.png

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...