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

IsMatch validation not working

I am creating a PowerApp form for a SharePoint List with two fields I want to have data validation on.  I use the required property of each field and have tried both of these formulas:

 

If(IsMatch(DataCardValue6.Text,"\d{7}") = false, true, false) - I tried this without the if statement as well and it did not work.  This field is simply a 7 digit number #######.

 

If(IsMatch(DataCardValue11.Text, Match.Digit & Digit & Digit & Match.Hyphen & Digit & Digit & Digit & Digit & Digit & Match.Hyphen & Digit & Digit & Digit & Digit & Match.Hyphen & Digit & Digit & Digit)=false, true, false) - Also tried without the if statement.  This is supposed to be a number formatted ###-#####-####-###.

 

I made the field required on the list, then made it not required, and both are limited in character length on the SharePoint list.  The problem I am having is I can save the record when I put alpha characters into the field.  What was also weird is when I tried to use the type ahead with the field name, it only had "ThisItem.Fieldname" and would not let me append it with ".Text."  This is why I used the DataCardValue# info.

1 ACCEPTED SOLUTION

Accepted Solutions

So I got it to work.  The formula I used needs to be on the Update property.  I used this formula and it's variant for the other field.

 

If(IsMatch(DataCardValue11.Text,"\d{3}-\d{5}-\d{4}-\d{3}"),DataCardValue11.Text)

 

I go the info from this article.

 

https://wonderlaura.com/2019/07/23/powerapps-text-input-pattern-validation/

 

Thank you everyone.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Example:
1234567
Formula:

IsMatch(Label1.Text,"\d{7}")

Result:
True

 

Example:
1234567
Formula:

 

Not(IsMatch(Label1.Text,"\d{7}"))

 

Result:
False

 

Example:

333-55555-4444-333

Formula:

IsMatch(Label1_1.Text,"\d{3}-\d{5}-\d{4}-\d{3}")

Result:

True

 

Use these as your validation before saving the record.

Sorry I have been off work the last couple of days.  I put the formulas you gave me in the required property for each of my 2 fields.  Use the Not() function got the required asterisk to disappear when the pattern was matched, but I am still able to save a new record with random text characters entered.  It is not "validating" to numbers only.

 

ScottRMeredith_0-1598053741333.png

 

I don't know if this matters, but I noticed I didn't specify this earlier.  These are SharePoint List forms customized in PowerApps.  I am using the buttons on the SharePoint List (New, Save, Cancel) that are built into the SharePoint List.

So I got it to work.  The formula I used needs to be on the Update property.  I used this formula and it's variant for the other field.

 

If(IsMatch(DataCardValue11.Text,"\d{3}-\d{5}-\d{4}-\d{3}"),DataCardValue11.Text)

 

I go the info from this article.

 

https://wonderlaura.com/2019/07/23/powerapps-text-input-pattern-validation/

 

Thank you everyone.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (1,902)