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

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
Super User
Super User

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.

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,996)