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

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...
 Share

×
×
  • Create New...