cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Infoudev
Level: Powered On

Add condition to input match

I have a form :

formpowerapps.PNG

 

editform.PNG

 

Like required felds error message , I would oblige user to put 6 digit code in the field "numero de symbole" . if he doesn't validate this condition an error message in red is shown

 

Ho can I do that ? If I should use Ismatch() where I have to put it. thanks

3 REPLIES 3
NEPatton
Level 8

Re: Add condition to input match

It sounds to me like you could use Ismatch here just fine.

 

There are probably numerous ways that you could implement this - but here's one to try out:

 

  1. Find wherever you use implement SubmitForm().
  2. Replace "SubmitForm()" with something like....
If(IsMatch(<text>,<Pattern>),Set(AcceptCode,1);SubmitForm(<thisForm>),Set(AcceptCode,0))

 

Walking through the IF statement -- If the user inputs a code that matches your pattern -- AcceptCode is set to 1 and the form is submitted.  If a user inputs a code that does NOT match your pattern -- AcceptCode is set to 0 and the form is NOT submitted.

 

The next step -- you can use the variable "AcceptCode" to change the formatting for boxes and visibility for text.  So, for instance...to control the color of the box for a TextInput control, we set the BorderColor parameter to something like...:

 

If(AcceptCode=1,Color.Black,Color.Red)

 

Contrast this implementation with the default implementation for forms:

If(IsBlank(Parent.Error), Parent.BorderColor, Color.Red)

 

However, if the identity cannot perform your required data validation -- Parent.Error is not going to catch this issue.  Ideally, we will combine both of these for your case, so you would want to do something like this:

 

If(IsBlank(Parent.Error) || (AcceptCode = 1), Parent.BorderColor, Color.Red)

 

Similarly, you can use AcceptCode to set the visibility on a Label that informs the user when they have not entered a correct code.

 

Does this help you out?

Infoudev
Level: Powered On

Re: Add condition to input match

Not yet working :

If I'm right, Power app Online Studio  dont accept comma , this is my function :

 

If(IsMatch(DataCardValue20.Text;"\d{6}");Set(AcceptCode;1);SubmitForm(EditForm1);Set(AcceptCode;0))

Form is always submitting even when I enter a digit code that doesn't match the pattern..

NEPatton
Level 8

Re: Add condition to input match

PowerApps Online Studio will accept comma.

 

, and ; do different things.  A quick explanation:

 

, is used to separate parameters in a function.

; is used to separate actions.

 

There are 2 ways to use an IF statement:

 

IF(<condition>, <Actions if True>)

or

IF(<condition>, <Actions if True>, <Actions if False>)

 

If you want to do more than one action for the TRUE case, then you use ; between each action for that parameter.  If you are getting errors, it would not be from using commas -- there must be another problem.  From your code below, I see multiple issues...most notably:

 

Set(AcceptCode;1); and Set(AcceptCode;0);

I'm a little surprised these aren't causing errors. Set is a fucntion:  Set(<variable>,<value) <---- it should use a comma.

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 205 members 4,853 guests
Please welcome our newest community members: