I wanted to be able to take the user input for a phone number (USA) and convert it to a formatted number, no matter how the user entered it. For example, 404.555.1234, or 404-555.1234, for example, would be nicely formatted to
(404) 555-1234
To do this, I did the following:
1. In the field template, on the Client Side tab, I added the field name to the Reset List and checked the Value field. (E.g., in the FIL:Phone field, I added itself to the reset list)
2. I added a string to the local data: L:String.
3. I added the following code to the embed:
Routines | 'Your Tab' | Field Name | 3 Value Routine
L:String=p_web.RestoreValue('FIL:Phone')
IF L:String
i#=0
n"=' '
LOOP LEN(CLIP(L:String)) TIMES
i#+=1
IF INSTRING(SUB(L:String,i#,1),'1234567890',1,1)
n"=CLIP(n") & SUB(L:String,i#,1)
END !IF L:INS...
END !Loop
p_web.SetSessionValue('FIL:Phone', FORMAT(n" , @p(###) ###-####p))
END !IF L:Str...
Now when the user tabs off the phone field, it formats the number correctly.