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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

secondImage

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (55,260)