cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ElizabethK
Helper III
Helper III

Validation for No Special Characters in a Phone Number Text Input

Hello,

 

I have a PowerApp connected to a SharePoint list with a number input box. This textbox is intended for a phone number, but we do not want any special characters. I made the range for the numbers in the SharePoint List 0-9. I tried using the validation:

 

IsMatch(DataCardValue5.Text,".*[\\\"&Char(34)&"/<>!@#$%^&*()].*") 

 

But it still is allowing me to type a period. Is there any way to eliminate the period? 

 

A gif below shows me still able to type the period, but not able to type the - or \ 

 

3F335F20-F0D1-4F42-84E5-02C5E784B5FF.GIF

 

Your help is appreciated! Thank you. 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@ElizabethK 

Ah my student 😊 where you went off the rail was in the third step - those formulas I provided were for the Visible property of your label.

In your second screen shot - that formula is correct if you are only going to allow users to enter 10 digits with no formatting in it.

The second formula (the one mentioned in my response as And for formatting allowed entry (I will be using the formatting allowed option from here on in this response):

That also was for the Visible property, but that formula would allow users to not only just enter 10 digits, but also, if they wanted to, to enter formatting characters.

You definitely do NOT want that on an OnChange action.

 

Let's fix that first and the look at the other scenario.  If they enter something that is not valid, then it should not let them submit.  So your wild entry should not have submitted.  And, it kind of does not submit that.

The way the formula was set up, if the entry was not valid, then it would have the existing phone number submitted.  This is why I mentioned the "There is some question in my mind on the Update formula only because we have not discussed some other "what if's"..."

Because, if a record has a phone number and a person chooses to enter a new one, but then does not add a valid number, it is really submitting the previous valid number and not the entered invalid number.

 

That can use some refinement I am sure, but since the "what if's" were a little murky in my mind for what you wanted, I took one route.  We can clean that up.  But for now, let's get the other issue fixed and see where things are.

 

Always happy to help 😁

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

15 REPLIES 15
RandyHayes
Super User
Super User

@ElizabethK 

Change your pattern to: 

IsMatch(DataCardValue5.Text,"^\d{10}$") 

This will return true if there are no other characters other than 10 digits.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hey Randy,

 

I am always thankful for your help.  Your suggestion was good but I do think that I am being mislead by the blog I am following in the first place. I attempted to attach a video for you to see what I was doing, but MP4s are not allowed so I will try to break it down and then add a little gif at the end.

 

The blog instructs: Add label (under datacard for phone number), set visible property to: 

IsMatch(DataCardValue2.Text,".*[\\\"&Char(34)&"/<>!@#$%^&*()].*")

 

Under the DisplayMode of your submit button enter this:

If(
 !lblWarning.Visible,
 DisplayMode.Edit,
 DisplayMode.Disabled
)

So forget all of that - if I do these steps but instead use the directions you provided me...it works, but I still can type a period technically and also it doesn't give me the error message I made the label for in the first place.

0B658FBA-8012-4559-9889-D1F1A78D4CC1.GIF

Thank you as always, @RandyHayes 

RandyHayes
Super User
Super User

@ElizabethK 

Yes, welcome to the world of misinformation in those PowerApps blogs and videos! 😫

 

For what you are trying to do, your Visible property on the warning label should be:

!IsMatch(DataCardValue5.Text,"^\d{10}$") 

This will display the label if the value is not 10 digits.

If you want to only display it once the user starts to type something in, then change it to the following:

!IsMatch(DataCardValue5.Text,"^\d{10}$") && !IsBlank(DataCardValue5.Text)

 

Your DisplayMode property for the submit button should be fine (although I would write it a little different as a ! (not) in this case, makes it a little backward in reading...correct, but not mentally easy). So, this would read a little better:

If(
 lblWarning.Visible,
 Disabled,
 Edit
)

 

Incidentally, the process (in regard to phone numbers) is to consider that a non-formatted, number-only phone number is more specific to your data storage and not to the human factor.  Humans in general, will want to see a formatted number as that makes more sense than 10 digits in a series.

SO, the concept is to provide formatting and allow formatting as much as possible and yet Always convert to digits and validate digits while ignoring formatting. This is a more user friendly and accurate way.

Obviously the choice is yours as the designer, but thought I would mention this.

Here is a little video example:

ElizabethK.gif

You can see the validity of the number is irrelevant to the formatting.  Users can do either that they like - as long as they provide a valid phone number...that is the end result. 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes 

I've bought you coffee before - but this is just ridiculous. You are so helpful to me, truly, thank you.

 

So now the special character warning I have displays as soon as I start writing the phone number. I made the visible property of the "must be a number between 0-9" false because it showed up right over the special character label I made. The submit button never appears to disable...which is fine, I don't care really, I just can't have them submitting something with characters.

DED728ED-C59F-4EB3-8C08-8F0240A2FC3E.GIF

 

What I am trying to accomplish here is just to ensure that when they put in a phone number, there are no special characters. I have powerautomated the responses of this form to be E-Mailed to a BOT that is being worked on by an IT Team. I agreed to make the information intake portion of the equation but the IT's feedback for me is that they cannot have any special characters in the phone number or it will make the BOT not work. The video solution you provided is the most ideal but beyond my current ability. 

RandyHayes
Super User
Super User

@ElizabethK 

Well, I can say that I certainly appreciate the coffee 🙂 And I'm always happy to help!

 

So...here is what I would suggest (and I am going to assume that the Phone Number is required in your form).

 

Actually...before I go into it, I should really verify that - is the Phone Number a required field?

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Good question. No phone is not required. The form inquires if they need to update the E-Mail (Yes or No dropdown) or Phone (Yes or No dropdown). Validations will make the "Enter E-Mail" or "Enter Phone" fields appear to provide that information based on the yes or no choice they choose from those two drop downs. If the user filling out the form only needs to update the E-Mail, we don't want them to be stopped by requiring phone - because of that, phone is not required. I have to log off for the day so no rush on this and truly thank you for your help. 

RandyHayes
Super User
Super User

@ElizabethK 

No problem...have a good evening and let me know tomorrow if the following statement is correct...

  IF they choose Yes in the dropdown to update the Phone Number - is it not then required?

There is a method to the madness of my question.  It has to do with the form, the Updates and the disabling of the button...all happy together!

 

Let me know when you get a chance.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
ElizabethK
Helper III
Helper III

@RandyHayes Answering from my phone now because it’s just that exciting to me!  Your statement is correct, if they select yes, even then it not a requirement to fill out phone. The BOT team requested this field not be required. Unclear as to why. Thank you so much and depending on you time zone have a good afternoon, evening or night! 

RandyHayes
Super User
Super User

@ElizabethK 

I'm Eastern US...so past the end of work here, but just can't break away!

 

So, here is the logic we need to figure out then.  If the phone number is not required...even if they select the change to be Just the Phone number, then what would make it invalid?

If the user selects Yes and enters nothing...that is good.

If the user selects Yes and enters 1 digit...that is not good.

If the user selects Yes and enters 10 digits (let's say formatted or not)...that is good.

 

Let me know if that logic is correct.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements

Calling all User Group Leaders and Super Users! Mark Your Calendars for the next Community Ambassador Call on May 9th!

This month's Community Ambassador call is on May 9th at 9a & 3p PDT. Please keep an eye out in your private messages and Teams channels for your invitation. There are lots of exciting updates coming to the Community, and we have some exclusive opportunities to share with you! As always, we'll also review regular updates for User Groups, Super Users, and share general information about what's going on in the Community.     Be sure to register & we hope to see all of you there!

April 2024 Community Newsletter

We're pleased to share the April Community Newsletter, where we highlight the latest news, product releases, upcoming events, and the amazing work of our outstanding Community members.   If you're new to the Community, please make sure to follow the latest News & Announcements and check out the Community on LinkedIn as well! It's the best way to stay up-to-date with all the news from across Microsoft Power Platform and beyond.    COMMUNITY HIGHLIGHTS   Check out the most active community members of the last month! These hardworking members are posting regularly, answering questions, kudos, and providing top solutions in their communities. We are so thankful for each of you--keep up the great work! If you hope to see your name here next month, follow these awesome community members to see what they do!   Power AppsPower AutomateCopilot StudioPower PagesWarrenBelzDeenujialexander2523ragavanrajanLaurensMManishSolankiMattJimisonLucas001AmikcapuanodanilostephenrobertOliverRodriguestimlAndrewJManikandanSFubarmmbr1606VishnuReddy1997theMacResolutionsVishalJhaveriVictorIvanidzejsrandhawahagrua33ikExpiscornovusFGuerrero1PowerAddictgulshankhuranaANBExpiscornovusprathyooSpongYeNived_Nambiardeeksha15795apangelesGochixgrantjenkinsvasu24Mfon   LATEST NEWS Business Applications Launch Event - On Demand In case you missed the Business Applications Launch Event, you can now catch up on all the announcements and watch the entire event on-demand inside Charles Lamanna's latest cloud blog.   This is your one stop shop for all the latest Copilot features across Power Platform and #Dynamics365, including first-hand looks at how companies such as Lenovo, Sonepar, Ford Motor Company, Omnicom and more are using these new capabilities in transformative ways. Click the image below to watch today!     Power Platform Community Conference 2024 is here! It's time to look forward to the next installment of the Power Platform Community Conference, which takes place this year on 18-20th September 2024 at the MGM Grand in Las Vegas!   Come and be inspired by Microsoft senior thought leaders and the engineers behind the #PowerPlatform, with Charles Lamanna, Sangya Singh, Ryan Cunningham, Kim Manis, Nirav Shah, Omar Aftab and Leon Welicki already confirmed to speak. You'll also be able to learn from industry experts and Microsoft MVPs who are dedicated to bridging the gap between humanity and technology. These include the likes of Lisa Crosbie, Victor Dantas, Kristine Kolodziejski, David Yack, Daniel Christian, Miguel Félix, and Mats Necker, with many more to be announced over the coming weeks.   Click here to watch our brand-new sizzle reel for #PPCC24 or click the image below to find out more about registration. See you in Vegas!     Power Up Program Announces New Video-Based Learning Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram. These include a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the image below to find out more!     UPCOMING EVENTS Microsoft Build - Seattle and Online - 21-23rd May 2024 Taking place on 21-23rd May 2024 both online and in Seattle, this is the perfect event to learn more about low code development, creating copilots, cloud platforms, and so much more to help you unleash the power of AI.   There's a serious wealth of talent speaking across the three days, including the likes of Satya Nadella, Amanda K. Silver, Scott Guthrie, Sarah Bird, Charles Lamanna, Miti J., Kevin Scott, Asha Sharma, Rajesh Jha, Arun Ulag, Clay Wesener, and many more.   And don't worry if you can't make it to Seattle, the event will be online and totally free to join. Click the image below to register for #MSBuild today!     European Collab Summit - Germany - 14-16th May 2024 The clock is counting down to the amazing European Collaboration Summit, which takes place in Germany May 14-16, 2024. #CollabSummit2024 is designed to provide cutting-edge insights and best practices into Power Platform, Microsoft 365, Teams, Viva, and so much more. There's a whole host of experts speakers across the three-day event, including the likes of Vesa Juvonen, Laurie Pottmeyer, Dan Holme, Mark Kashman, Dona Sarkar, Gavin Barron, Emily Mancini, Martina Grom, Ahmad Najjar, Liz Sundet, Nikki Chapple, Sara Fennah, Seb Matthews, Tobias Martin, Zoe Wilson, Fabian Williams, and many more.   Click the image below to find out more about #ECS2024 and register today!   Microsoft 365 & Power Platform Conference - Seattle - 3-7th June If you're looking to turbo boost your Power Platform skills this year, why not take a look at everything TechCon365 has to offer at the Seattle Convention Center on June 3-7, 2024.   This amazing 3-day conference (with 2 optional days of workshops) offers over 130 sessions across multiple tracks, alongside 25 workshops presented by Power Platform, Microsoft 365, Microsoft Teams, Viva, Azure, Copilot and AI experts. There's a great array of speakers, including the likes of Nirav Shah, Naomi Moneypenny, Jason Himmelstein, Heather Cook, Karuana Gatimu, Mark Kashman, Michelle Gilbert, Taiki Y., Kristi K., Nate Chamberlain, Julie Koesmarno, Daniel Glenn, Sarah Haase, Marc Windle, Amit Vasu, Joanne C Klein, Agnes Molnar, and many more.   Click the image below for more #Techcon365 intel and register today!   For more events, click the image below to visit the Microsoft Community Days website.    

Tuesday Tip | Update Your Community Profile Today!

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   We're excited to announce that updating your community profile has never been easier! Keeping your profile up to date is essential for staying connected and engaged with the community.   Check out the following Support Articles with these topics: Accessing Your Community ProfileRetrieving Your Profile URLUpdating Your Community Profile Time ZoneChanging Your Community Profile Picture (Avatar)Setting Your Date Display Preferences Click on your community link for more information: Power Apps, Power Automate, Power Pages, Copilot Studio   Thank you for being an active part of our community. Your contributions make a difference! Best Regards, The Community Management Team

Hear what's next for the Power Up Program

Hear from Principal Program Manager, Dimpi Gandhi, to discover the latest enhancements to the Microsoft #PowerUpProgram, including a new accelerated video-based curriculum crafted with the expertise of Microsoft MVPs, Rory Neary and Charlie Phipps-Bennett. If you’d like to hear what’s coming next, click the link below to sign up today! https://aka.ms/PowerUp  

Tuesday Tip: Community User Groups

It's time for another TUESDAY TIPS, your weekly connection with the most insightful tips and tricks that empower both newcomers and veterans in the Power Platform Community! Every Tuesday, we bring you a curated selection of the finest advice, distilled from the resources and tools in the Community. Whether you’re a seasoned member or just getting started, Tuesday Tips are the perfect compass guiding you across the dynamic landscape of the Power Platform Community.   As our community family expands each week, we revisit our essential tools, tips, and tricks to ensure you’re well-versed in the community’s pulse. Keep an eye on the News & Announcements for your weekly Tuesday Tips—you never know what you may learn!   Today's Tip: Community User Groups and YOU Being part of, starting, or leading a User Group can have many great benefits for our community members who want to learn, share, and connect with others who are interested in the Microsoft Power Platform and the low-code revolution.   When you are part of a User Group, you discover amazing connections, learn incredible things, and build your skills. Some User Groups work in the virtual space, but many meet in physical locations, meaning you have several options when it comes to building community with people who are learning and growing together!   Some of the benefits of our Community User Groups are: Network with like-minded peers and product experts, and get in front of potential employers and clients.Learn from industry experts and influencers and make your own solutions more successful.Access exclusive community space, resources, tools, and support from Microsoft.Collaborate on projects, share best practices, and empower each other. These are just a few of the reasons why our community members love their User Groups. Don't wait. Get involved with (or maybe even start) a User Group today--just follow the tips below to get started.For current or new User Group leaders, all the information you need is here: User Group Leader Get Started GuideOnce you've kicked off your User Group, find the resources you need:  Community User Group ExperienceHave questions about our Community User Groups? Let us know! We are here to help you!

Super User of the Month | Ahmed Salih

We're thrilled to announce that Ahmed Salih is our Super User of the Month for April 2024. Ahmed has been one of our most active Super Users this year--in fact, he kicked off the year in our Community with this great video reminder of why being a Super User has been so important to him!   Ahmed is the Senior Power Platform Architect at Saint Jude's Children's Research Hospital in Memphis. He's been a Super User for two seasons and is also a Microsoft MVP! He's celebrating his 3rd year being active in the Community--and he's received more than 500 kudos while authoring nearly 300 solutions. Ahmed's contributions to the Super User in Training program has been invaluable, with his most recent session with SUIT highlighting an incredible amount of best practices and tips that have helped him achieve his success.   Ahmed's infectious enthusiasm and boundless energy are a key reason why so many Community members appreciate how he brings his personality--and expertise--to every interaction. With all the solutions he provides, his willingness to help the Community learn more about Power Platform, and his sheer joy in life, we are pleased to celebrate Ahmed and all his contributions! You can find him in the Community and on LinkedIn. Congratulations, Ahmed--thank you for being a SUPER user!  

Top Solution Authors
Top Kudoed Authors
Users online (4,274)