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

Disable button based off empty dropdown value

I have an excel spreadsheet table that feeds my dropdown box values in Powerapps. I left an empty cell so that I can have an empty value as the first selection in my dropdown box.

 

I need to disable the submit button if the empty value is selected. I don't want the user to submit the form if the empty value is selected. I figured out how to disable the button for the "traffic" value but I do not know the name of that empty value to make my formula work. See screen shots.

 

Please help Smiley Happy

 

If((Reasons_DD).Selected.Value = "Traffic",DisplayMode.Disabled,DisplayMode.Edit)

 

Capture_reasons.JPG

 

 

 

 

 

 

 

 

 

 

 

 

Capturedropdown.JPG

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Super User
Super User

Re: Disable button based off empty dropdown value

Hey @ersula82, try this:

 

If(IsBlank(Reasons_DD.Selected.Value),DisplayMode.Disabled,DisplayMode.Edit)
Super User
Super User

Re: Disable button based off empty dropdown value

@ersula82 Try this: 

 

If(
Or(
IsBlank(Reasons_DD.Selected.Value),
And(
IsBlank(Other_Txtbox.Text),
Other_Txtbox.Visible
)
),
DisplayMode.Disabled,
DisplayMode.Edit
)

This is assuming that the Other_Txtbox is only visible when it is able to be used, and thus if it is visible it should not be blank either. Let me know if that works out for you.

14 REPLIES 14
Super User
Super User

Re: Disable button based off empty dropdown value

Hey @ersula82, try this:

 

If(IsBlank(Reasons_DD.Selected.Value),DisplayMode.Disabled,DisplayMode.Edit)
ersula82
Level: Powered On

Re: Disable button based off empty dropdown value

That worked! I tried that earlier but I think I put my parenthesis in the wrong place. Awesome!

Super User
Super User

Re: Disable button based off empty dropdown value

Glad to hear it worked for you!
ersula82
Level: Powered On

Re: Disable button based off empty dropdown value

@wyotim a quick question, in that same dropdown box I have an "other" option which when selected displays a textbox for the user to type in.

I need to disable the submit button both if the textbox is blank OR if the dropdown value is blank. 

 

Right now both of the below formulas work on their own but I've tried to figure out how to combine them and it's not accepting anything I type.

 

Disable the button if the text box is blank:

If(IsBlank(Other_Txtbox),DisplayMode.Disabled,DisplayMode.Edit)

 

Disable the button if the dropdown value is blank:

If(IsBlank(Reasons_DD),DisplayMode.Disabled,DisplayMode.Edit)

 

Help!

Capturedropdown.JPG

 

CaptureOtherBox.JPG

 

 

 

 

 

Super User
Super User

Re: Disable button based off empty dropdown value

@ersula82 Try this: 

 

If(
Or(
IsBlank(Reasons_DD.Selected.Value),
And(
IsBlank(Other_Txtbox.Text),
Other_Txtbox.Visible
)
),
DisplayMode.Disabled,
DisplayMode.Edit
)

This is assuming that the Other_Txtbox is only visible when it is able to be used, and thus if it is visible it should not be blank either. Let me know if that works out for you.

ersula82
Level: Powered On

Re: Disable button based off empty dropdown value

@wyotim this worked although I'm a little confused on the nesting statement but I guess I'll continue to learn as I go along. I was literally up for hours attempting every if statement variation I can think of so thank you for your speedy reply. You saved me time!

 

Ersula

Super User
Super User

Re: Disable button based off empty dropdown value

@ersula82 Glad it worked out! I will post an explanation of the nested statement, hopefully tonight but definitely by tomorrow.

 

In my mind, it’s only a solution if it is repeatable and understood so I am happy to get into the details and make it as clear as I can.

Super User
Super User

Re: Disable button based off empty dropdown value

Okay, here we go on this explanation. This may be something you already know, so forgive me if this is too basic but I thought I would get into the And() and Or() functions. Without going too in depth or getting to basic, these functions compare two or more Boolean (true or false) statements and return a true or false based on the result.

 

For And(), if all the compared statements are true, it returns true; otherwise, it returns false.

 

For Or() if just one of the compared statements is true, it returns true; otherwise, it returns false.

 

I can go more in-depth on these if you like, but that is the general idea.

 

For the specific code, I will start with the And() section. The two statements it compares are:

 

1) if the Other_Txt text is blank and

2) if the Other_Txt label is visible.

 

To return true, both of these statements must be true (i.e. the text is blank and the label is visible). Otherwise (i.e. if the text is not blank or the label is not visible), it will return false. Since the visibility of the Other_Txt input area is tied to the selection of "Other" in the Reasons_DD drop down, it is that selection that will trigger this statement. If it never becomes visible (i.e. "Other" is not selected), it will return false. 

 

For the Or() section, we use:

 

1) if the Reasons_DD drop down has nothing selected and

2) the result of the previous And() section.

 

For this to return true, just one of those needs to be true (i.e. Reasons_DD dropdown has nothing selected or both the Other_Txt text is empty and the Other_Txt label is visible). Otherwise, it will return false.

 

Now, the result of the Or() statement is what then sets the true or false section of the If() statement. If it is true (meaning that the necessary areas are not selected/filled out), the item is disabled. Otherwise, it will be enabled.

 

I am typing this on very little sleep so I hope it makes sense. Feel free to comment back if I need to better word things or if it was total gibberish.  

 

ersula82
Level: Powered On

Re: Disable button based off empty dropdown value

@wyotim that explanation was perfect and helped alot. So, with that understanding, I was able to add a 3rd condition on the Or Statement that I needed to add. I would not have been able to do so without your teaching so thank you! 

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: 47 members 4,900 guests
Please welcome our newest community members: