cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

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

@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

@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 

@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. 

@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. 

@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!

@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! 

@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

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages