How can I use scripting to make " - " or " , " disappear if the phone or cellphone fields are left blank?

EDOCBUILDER > eDocBuilder FAQs > Field Scripting
How can I use scripting to make " - " or " , " disappear if the phone or cellphone fields are left blank?
 
Scenario: Your customer has a business card and wants to allow people to include their phone and cellphone in the same line, separated by a dash " - " or a comma " , ". The result would be:

Tel. 000.000.000 - Cell. 000.000.000
Tel. 000.000.000 , Cell. 000.000.000

This is possible only through Vb Scripting, not through HTML field scripting.
The Vb Script you would use is:
 
ifs(phone<>"", "Tel." & phone & "","") & ifs(phone<>"", ifs(cellphone<>"", " - ", "") & ifs(cellphone<>"", "Cell. " & cellphone & "","")
Click here for testing.

Notes:
 
1) Before pasting this script from this knowledge base article into your field's Field Scripting tab, please paste it into Notepad or another plain text editor. Then re-copy it and paste it into your template so that no formatting is carried over from the web version.
 
2) This script assumes that your fields are named Phone and Cellphone. You will need to adjust your script to match the field names of your own template.
 
3) Looking at the very first part of the script, you can see the basic setup of an expression in VB script:
 
ifs(phone<>"",  "Tel, "& phone & " ", "")
 
This basically says: If the Phone field is different from blank, then enter the Tel. and the information introduced on the phone field, otherwise left in blank.