Auto-formating Phone Numbers in InfoPath Form - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Auto-formating Phone Numbers in InfoPath Form

Last post 08-11-2020 04:36 PM by Evanz. 6 replies.
Page 1 of 1 (7 items)
Sort Posts: Previous Next
  • 08-05-2020 06:01 PM

    • Evanz
    • Top 500 Contributor
    • Joined on 04-16-2020
    • Posts 31

    Auto-formating Phone Numbers in InfoPath Form

     Hi,

    Is it possible to set auto-formatting phone number field in InfoPath form? if yes, what code would be using? any assistance would be much appreciated.

    Thank you, 

  • 08-06-2020 06:57 PM In reply to

    Re: Auto-formating Phone Numbers in InfoPath Form

    Hmmmm. I mean.... maybe? Perhaps you could use translate to remove everything that isn't a number, then split it up and add in the parenthesis and the dash... but then, who knows if someone is going to add a country code or something. That might get a little tricky. Maybe have a field (number only) for country code (if needed) and another field (number only) for phone, and then display it formatted in a calculated value? I just can't think of a robust way to do this with rules / form logic.....
    Hilary Stoupa

  • 08-10-2020 11:15 AM In reply to

    • Evanz
    • Top 500 Contributor
    • Joined on 04-16-2020
    • Posts 31

    Re: Auto-formating Phone Numbers in InfoPath Form

     Hi, thank you for your prompt response! since the form created for the company's internal use only, so it should have to be 10 digit numbers that I did not even think about adding a country code or something, etc...:-)

     Below is a calculate value that I have been searching for from google but I am not sure if it works or do I have to use any rule/condition? Any advices? I really appreciate it.

     concat("(", substring(translate(., "()-", ""), 1, 3), ")", substring(translate(., "()-", ""), 4, 3), "-", substring(translate(., "()-", ""), 7, 4))

  • 08-11-2020 08:36 AM In reply to

    Re: Auto-formating Phone Numbers in InfoPath Form

    Where do you intend to use this? It looks like it would be for the field if only numbers were entered... In which case, in a rule on the field you wish to format, set the same field using this formula, probably with a condition that the field doesn't contain () or -. See attached sample - save the file locally, right click and select design.
    Hilary Stoupa

  • 08-11-2020 12:17 PM In reply to

    • Evanz
    • Top 500 Contributor
    • Joined on 04-16-2020
    • Posts 31

    Re: Auto-formating Phone Numbers in InfoPath Form

     Yes, It's a field just for entering numbers. Thank you very much for your sample. It's very helpful. :-). Just one more question, is it possible to add another condition into your sample provided that if user enter more than or less than 10 digit phone numbers, the phone number field will display a red margin around the field? I mean user should enter the correct 10 digit numbers for this field. Any hint? Thanks again. :-)

  • 08-11-2020 03:33 PM In reply to

    Re: Auto-formating Phone Numbers in InfoPath Form

    Here, I added a validation rule. :-)
    Hilary Stoupa

  • 08-11-2020 04:36 PM In reply to

    • Evanz
    • Top 500 Contributor
    • Joined on 04-16-2020
    • Posts 31

    Re: Auto-formating Phone Numbers in InfoPath Form

    Thank you for your quick response. It works perfectly as to what I am looking for. You're the best Hilary! Much appreciated. :) You have a wonderful evening!

Page 1 of 1 (7 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.