cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
neill_long
Helper V
Helper V

Button disabled if fields are empty and dropdown = certain value

I am creating a form which the data will get saved to a collection and i would like to disable the button until all the fields are filled in. 

 

Here is what i have on the buttons displaymode:

If(Site_Drop.Selected.Value = "Please select" && Start_Drop.Selected.Value = "Please select" && End_Drop.Selected.Value = "Please select" && Recurring_Drop.Selected.Value = "Please select" && IsBlank(Dept_Text.Text) && IsBlank(Number_Text.Text) ,Disabled, Edit)

If all the fields are empty then the button is disabled.  But as soon as text is entered into 1 of the fields, the button is enabled regardless of the fact the other fields still need data.

 

 

The form consists of 4 dropdowns and 2 textinput fields.  All the dropdowns have "Please select" as the first option,  so if this is what is displayed then the button should be disabled.

 

Can anyone advise where i have gone wrong in my If statement please?

 

thanks in advance.

Alistair

1 ACCEPTED SOLUTION

Accepted Solutions
Drrickryp
Super User
Super User

@neill_long,

Your statement reduces to disabled if all criteria are met.  What that means is that if one of the criteria is false, then the entire statement is false and the button is enabled.  What you need is for the button to be disabled unless all criteria are true.  By replacing the && with || , I believe that the statement reduces to true if any of the conditions are true, then the button will be disabled. 

If(Site_Drop.Selected.Value = "Please select" || Start_Drop.Selected.Value = "Please select"|| End_Drop.Selected.Value = "Please select" || Recurring_Drop.Selected.Value = "Please select" || IsBlank(Dept_Text.Text) || IsBlank(Number_Text.Text) ,Disabled, Edit)

 

View solution in original post

5 REPLIES 5
Drrickryp
Super User
Super User

@neill_long,

Your statement reduces to disabled if all criteria are met.  What that means is that if one of the criteria is false, then the entire statement is false and the button is enabled.  What you need is for the button to be disabled unless all criteria are true.  By replacing the && with || , I believe that the statement reduces to true if any of the conditions are true, then the button will be disabled. 

If(Site_Drop.Selected.Value = "Please select" || Start_Drop.Selected.Value = "Please select"|| End_Drop.Selected.Value = "Please select" || Recurring_Drop.Selected.Value = "Please select" || IsBlank(Dept_Text.Text) || IsBlank(Number_Text.Text) ,Disabled, Edit)

 

@Drrickryp

thank you, works perfectly now.

Hi. I would like to find out what would be the code if all dropdowns where have to be true for the button to be enabled.??since you used two || .must I use one.??

Hi @Sibalukhulu 

"||" is a shortcut for the OR condition.  You can use as many as necessary to complete the logic of the IF() function. 

Thank you it worked 

Helpful resources

Announcements
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,896)