Jump to content

Phone formtting


kenstraker

Recommended Posts

Assuming your data is always in a 4-3-3 digit format, 12 characters total, you will need to make minor changes to Don's suggestion, in red, below.

 

return Left(Field("YOURFIELD"),4)+" "+Left(Right(Field("YOURFIELD"),[color="red"]7[/color]),3)+" "+Right(Field("YOURFIELD"),3)[color="Red"];[/color]

 

 

Taking this approach and depending on your data, you might want to strip out the spaces first. You could try:

 

var str = Field("YourField");//Replace with your field name
var newStr = str.replace(/\s+/g, '');

return Left(newStr,4) + " " + Left(Right(newStr,6),3) + " " + Right(newStr,3);

 

Or maybe, strip out spaces and hyphens first. Additions are in red:

 

var str = Field("YourField");//Replace with your field name
var newStr = str.replace(/\s+[color="red"]|-[/color]/g, '');

return Left(newStr,4) + " " + Left(Right(newStr,6),3) + " " + Right(newStr,3)

 

et cetera...

 

There are probably more efficient ways of accomplishing this.

Edited by David Miller
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.

×
×
  • Create New...