Telephone format in text control - InfoPath Dev Sign in | Join | Help in Newbie Questions InfoPath (Entire Site) InfoPath Dev InfoPath Dev is dedicated to bringing you the information and tools you need to be successful in your Microsoft Office InfoPath development projects. Home Blogs Forums Photos Downloads InfoPath Dev » InfoPath » Newbie Questions » Telephone format in text control Telephone format in text control Last post 04-11-2015 05:29 PM by djm50. 31 replies. Page 1 of 3 (32 items) 1 2 3 Next > Sort Posts: Oldest to newest Newest to oldest Previous Next 10-08-2008 07:04 PM cbrown00 Joined on 04-17-2008 Posts 66 Telephone format in text control Reply Contact Is there a way to configure a text box control to format numbers entered into telephone format (xxx) yyy-zzzz? 10-08-2008 09:46 PM In reply to Mel Clemente Joined on 08-06-2008 Philippines Posts 340 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact Hello and welcome to the board!Try the following steps:1. Add a rule to your textbox control with the following conditions (make sure to select "and" operator): a. field "does not match pattern" Phone number b. the expression: string-length(translate(., "()- ", "")) = 10 c. the expression: string-length(translate(., "()- 0123456789", "")) = 02. Add action to the rule: a. Set a field's value b. Select your textbox field c. Insert formula for the value (click the fx button): concat("(", substring(translate(., "()- ", ""), 1, 3), ") ", substring(translate(., "()- ", ""), 4, 3), "-", substring(translate(., "()- ", ""), 7, 4)) That should work like a charm!Good luck! Mel ClementeQdabra® Software/ InfoPathDev.comThe InfoPath Experts – Streamline data gathering to turn process into knowledge.™ Filed under: phone number format 10-08-2008 10:22 PM In reply to cbrown00 Joined on 04-17-2008 Posts 66 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact Worked like a champ..thanks! 10-08-2008 11:06 PM In reply to Mel Clemente Joined on 08-06-2008 Philippines Posts 340 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact Yey!Glad it did! :) Mel ClementeQdabra® Software/ InfoPathDev.comThe InfoPath Experts – Streamline data gathering to turn process into knowledge.™ 04-29-2010 10:33 AM In reply to CheyLaw Joined on 04-29-2010 Posts 1 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact I've noticed that sometimes people will input a number as 555.555.5555, and the functions above don't work as they should. To get around this, modify it just a bit:1. Add a rule to your textbox control with the following conditions (make sure to select "and" operator): a. field "does not match pattern" Phone number b. the expression: string-length(translate(., "()-. ", "")) = 10 c. the expression: string-length(translate(., "()-. 0123456789", "")) = 0 2. Add action to the rule: a. Set a field's value b. Select your textbox field c. Insert formula for the value (click the fx button): concat("(", substring(translate(., "()-. ", ""), 1, 3), ") ", substring(translate(., "()-. ", ""), 4, 3), "-", substring(translate(., "()-. ", ""), 7, 4)) 09-10-2010 09:23 AM In reply to SP Cortez Joined on 07-21-2010 Posts 3 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact This is Great. Thanks for posting. I was curious, how would you modify it to accomodate country codes. Like +1 (800) 555-1212 02-25-2011 05:27 AM In reply to monkman Joined on 02-25-2011 Posts 1 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact so when you setup the text box is it a string or whole number, is there a need to set the max amount of characters allowed? and this would be a validation 03-07-2011 01:42 PM In reply to tafavorite Joined on 02-01-2011 Posts 65 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact When I set mine up I did it as a text (String) so that users could be able to enter () and - if they wanted. Then I set the validation up to only allow phone number pattern and told the user in a pop up that only 10 numbers could be entered. If you really want the brake down I can give it out there, but try this first and messing around with the validation rules! Its really up to what you want it to do. If you only want it to accept numbers and users would understand that, then that is the route I would go. We had to go this route becuase so many users its hard to know that all of them would know to enter just numbers. Good luck. 03-10-2011 10:52 AM In reply to nithra Joined on 03-09-2011 Posts 3 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact Hi, Thanks for your posting.I need a help in setting formatting elements in text box.I need a mask in text box which should be in this format (_____-____-___-____-____) so that user can enter specific text within tthis. Soonest reply will be so helpful. Nithra 01-17-2013 11:09 AM In reply to KTFontNo Joined on 01-17-2013 Posts 1 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact Mel Balsamo:c. Insert formula for the value (click the fx button): concat("(", substring(translate(., "()- ", ""), 1, 3), ") ", substring(translate(., "()- ", ""), 4, 3), "-", substring(translate(., "()- ", ""), 7, 4)) Mel, How would you write a formula that accepts both (000) 000-0000 and 0-000-000-0000 formats? I'd like for my users to be able to insert both phone patterns into the text box control. Thanks, KT Filed under: Validation, Controls, phone number format, Conditional Formatting InfoPath, conditional formatting 01-21-2013 01:00 AM In reply to john111 Joined on 01-18-2013 Posts 6 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact wow the complete code. thanks for sharing. it helped me a lot in solving my problem though 11-26-2013 12:21 PM In reply to momk15 Joined on 11-26-2010 Posts 16 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact I am trying to do the following formatting. I understand what is being done but I cant seem to get it to work. I need users to type 32 characters in to a field and then it automatically formats it like this: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx any help please? 11-28-2013 11:05 AM In reply to Mel Clemente Joined on 08-06-2008 Philippines Posts 340 Re: Telephone format in text control PostID=94534.xsn Mark as Not AnswerMark as Answer... Reply Contact Hi,I attached a sample XSN that does what you want. Check out the rule in field1 - you'll see that it first checks if the length is 32 characters, and then it builds the string using the formula:concat(substring(., 1, 2), ":", substring(., 3, 2), ":", substring(., 5, 2), ":", substring(., 7, 2), ":", substring(., 9, 2), ":", substring(., 11, 2), ":", substring(., 13, 2), ":", substring(., 15, 2), ":", substring(., 17, 2), ":", substring(., 19, 2), ":", substring(., 21, 2), ":", substring(., 23, 2), ":", substring(., 25, 2), ":", substring(., 27, 2), ":", substring(., 29, 2), ":", substring(., 31, 2)) Hope that helps! Mel ClementeQdabra® Software/ InfoPathDev.comThe InfoPath Experts – Streamline data gathering to turn process into knowledge.™ 12-11-2013 07:42 AM In reply to Jess154 Joined on 01-16-2013 Posts 7 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact I have this in use, but if a user enters only their extension (Ex. 75078), this is accepted in the field and will appear as (750) 78. How can I make it required that 10 digits MUST be entered? 12-11-2013 04:45 PM In reply to Mel Clemente Joined on 08-06-2008 Philippines Posts 340 Re: Telephone format in text control Mark as Not AnswerMark as Answer... Reply Contact You can add a data validation rule that checks the character count, for example: string-length(my:phoneNumber) < 10 Mel ClementeQdabra® Software/ InfoPathDev.comThe InfoPath Experts – Streamline data gathering to turn process into knowledge.™ Page 1 of 3 (32 items) 1 2 3 Next > Copyright © 2003-2019 Qdabra Software. All rights reserved.View our Terms of Use.
Is there a way to configure a text box control to format numbers entered into telephone format (xxx) yyy-zzzz?
Hello and welcome to the board!Try the following steps:1. Add a rule to your textbox control with the following conditions (make sure to select "and" operator): a. field "does not match pattern" Phone number b. the expression: string-length(translate(., "()- ", "")) = 10 c. the expression: string-length(translate(., "()- 0123456789", "")) = 02. Add action to the rule: a. Set a field's value b. Select your textbox field c. Insert formula for the value (click the fx button): concat("(", substring(translate(., "()- ", ""), 1, 3), ") ", substring(translate(., "()- ", ""), 4, 3), "-", substring(translate(., "()- ", ""), 7, 4))
That should work like a charm!
Good luck!
Worked like a champ..thanks!
Yey!
Glad it did! :)
I've noticed that sometimes people will input a number as 555.555.5555, and the functions above don't work as they should. To get around this, modify it just a bit:
This is Great. Thanks for posting.
I was curious, how would you modify it to accomodate country codes. Like +1 (800) 555-1212
so when you setup the text box is it a string or whole number, is there a need to set the max amount of characters allowed?
and this would be a validation
When I set mine up I did it as a text (String) so that users could be able to enter () and - if they wanted. Then I set the validation up to only allow phone number pattern and told the user in a pop up that only 10 numbers could be entered. If you really want the brake down I can give it out there, but try this first and messing around with the validation rules! Its really up to what you want it to do. If you only want it to accept numbers and users would understand that, then that is the route I would go. We had to go this route becuase so many users its hard to know that all of them would know to enter just numbers. Good luck.
Hi,
Thanks for your posting.I need a help in setting formatting elements in text box.I need a mask in text box which should be in this format (_____-____-___-____-____) so that user can enter specific text within tthis.
Soonest reply will be so helpful.
Nithra
Mel Balsamo:c. Insert formula for the value (click the fx button): concat("(", substring(translate(., "()- ", ""), 1, 3), ") ", substring(translate(., "()- ", ""), 4, 3), "-", substring(translate(., "()- ", ""), 7, 4))
I attached a sample XSN that does what you want. Check out the rule in field1 - you'll see that it first checks if the length is 32 characters, and then it builds the string using the formula:
concat(substring(., 1, 2), ":", substring(., 3, 2), ":", substring(., 5, 2), ":", substring(., 7, 2), ":", substring(., 9, 2), ":", substring(., 11, 2), ":", substring(., 13, 2), ":", substring(., 15, 2), ":", substring(., 17, 2), ":", substring(., 19, 2), ":", substring(., 21, 2), ":", substring(., 23, 2), ":", substring(., 25, 2), ":", substring(., 27, 2), ":", substring(., 29, 2), ":", substring(., 31, 2))
Hope that helps!
I have this in use, but if a user enters only their extension (Ex. 75078), this is accepted in the field and will appear as (750) 78. How can I make it required that 10 digits MUST be entered?