QLingo code for formatting user entered phone number

616 views
Skip to first unread message

cda...@tucsoncps.com

unread,
Apr 26, 2016, 8:49:17 PM4/26/16
to XMPie Interest Group
I have the following QLingo code:

if(Length(Trim(|->[Ph1])) > 0)
{
    if(|->[PhLbl1] <> "")
    {
        |->[PhLbl1] & ": " & FormatNumber(|->[Ph1], "(###) ###-####")
    }
    else
    {
        FormatNumber(|->[Ph1], "(###) ###-####")
    }
}
else
{
    ""
}

How do I implement the logic to strip out any other user input (i.e., 'xxxxxxxxxx' or  'xxx.xxx.xxxx' or '+1 (xxx) xxx.xxxx', etc.) and force the formatting to always be '(xxx) xxx-xxxx' so that the user does not need to worry about how they are entering text at the store page?

George Marsh

unread,
Apr 27, 2016, 12:37:58 AM4/27/16
to xmpie...@googlegroups.com
Search for the recent thread "newbie formatting question"

Message has been deleted

cda...@tucsoncps.com

unread,
Apr 27, 2016, 12:06:05 PM4/27/16
to XMPie Interest Group
Thank you gxm, your suggestion yielded some good info, and I like that I can control this from within the VDP item itself, but since my initial question I have come across another possible elegant solution that I am hoping someone could help me implement within uStore itself.

I've come across references that Javascript, etc., can be incorporated into the uStore dial details for the ADOR field in question and saw an example of restricting (or formatting) from the user's perspective of their input into a particular desired format, in my case...the dial "Ph1" for a user entered phone number. I have a QLingo rule expression in place for a particular business card product that combines this input with another ADOR dial which is configured as a drop-down field ("PhLbl1") for the user to select a label prefix such as "Phone:" or "Cell:" etc. So for example, "Phone: (123) 456-7890"

"Ph1" QLingo code:
if (!IsNullOrEmpty(|->[Ph1])) {
    if(!IsNullOrEmpty(|->[PhLbl1])) {
        |->[PhLbl1] & ": " & |->[Ph1]
    } else {
        |->[Ph1]
    }
} else {
    ""
}

In the context of formatting the users input, I have come across the following jQuery masked input library, and am wondering how this might be integrated into masking user input which might make a QLingo formatting expression redundant, allowing me to just use the QLingo code above?

couch

unread,
Apr 28, 2016, 6:04:22 PM4/28/16
to XMPie Interest Group
If you want to have more control over the way the user inputs data into the dial, then I suggest you investigate the HTML Generic Dial controls. - You can do some nice things with jquery or other javascript libraries.
Reply all
Reply to author
Forward
0 new messages