Showing results for 
Search instead for 
Did you mean: 
Frequent Visitor

In Gallery, Validate on control based on another control.

In a gallery (galItems), there is a dropdownlist (ddlStatus) for Status (Pass, Fail, Ignore), and a textbox (txtComments) field. If the Status="Fail", the Comments field cannot be blank. 


What is the PowerApps way to implement this validation when a Save button is selected?


This page doesn't really provide enough information nor good examples: Validate function in Power Apps - Power Apps | Microsoft Docs

Super User
Super User

You can't actually 'require' fields in Power Apps.    What you can do is a workaround.    I am going to give an example that presumes your save button is in the individual gallery item.


Add a 10 x 10 label with an Asterisk in it (red color) and put it to the right or left of your comment field in the gallery.   Set it's visible property to:

ddlStatus.selected.XXX = "Fail" && IsBlank(txtComments)


Follow the same logic and set the displaymode property of the save button to view.


  ddlStatus.Selected.XXX = "Fail" && IsBlank(txtComments), DisplayMode.View, DisplayMode.Edit


If you like this post, give it a Thumbs up. If it answered your question, Mark it as a Solution to enable other users find it.
Community Support
Community Support


Do you want to validate the status and comments field when you submit?

Could you please share a bit more about your scenario?


Firstly, you should put a validation within the Comments field by setting the HintText text input as below:

If(ddlStatus.Selected.Value="Fail"&& IsBlank(TextInput1.Text),"Here should have inputs!","")

Set the save button OnSelect property as below:

If(!IsBlank(TextInput1.HintText),Notify("Comments field cannot be blank, please fill in!",Error))
Best Regards,
Frequent Visitor

Here's what I did...


In txtComments.Fill: 
If(ddlResult.Selected.Value = "At Risk" && IsBlank(txtComments),
RGBA(255, 0, 0, 1),
RGBA(255, 255, 255, 1)


In btnSubmit.OnSelect: 


Notify("At Risk items must have a comment. Please update " & varValidationCnt & " row(s)"),
If(CountRows(colObsItems) > 0,
Patch('MySharePointListName', colObsItems);
Notify(CountRows(colObsItems) &
" detail item(s) were saved", NotificationType.Information);

Helpful resources

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,568)