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

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
EricLott
Community Champion
Community Champion

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
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Top Kudoed Authors
Users online (3,677)