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

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

Re: Button disabled if fields are empty and dropdown = certain value

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

Re: Button disabled if fields are empty and dropdown = certain value

@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

neill_long
Level: Powered On

Re: Button disabled if fields are empty and dropdown = certain value

@Drrickryp

thank you, works perfectly now.

Sibalukhulu
Level: Powered On

Re: Button disabled if fields are empty and dropdown = certain value

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

Re: Button disabled if fields are empty and dropdown = certain value

Hi @Sibalukhulu 

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

Sibalukhulu
Level: Powered On

Re: Button disabled if fields are empty and dropdown = certain value

Thank you it worked 

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,345)