web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How can I disable a bu...
Power Apps
Unanswered

How can I disable a button based on all Combo Boxes and Text Inputs are filled in?

(0) ShareShare
ReportReport
Posted on by

Hello PowerApps Community,

 

I am looking for some help on disabling this button unless all combo boxes & Text Inputs have input.

 

Here are my OnSelect values

(ComboBox1.Selected.Value, ComboBox4.Selected.DisplayName, TextInput1.Text, User().Email, TextInput2.Text, ComboBox4.Selected.Mail);

 

Masum172_0-1676700665942.png

 

It would be a massive help if someone can advise as it is driving me nuts! I have tried a few suggestions online but unfortunately had no luck, any help is appreciated thanks!

Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,084 Most Valuable Professional on at

    HI @Masum172 ,

    Something like this should do it

    If(
     Len(ComboBox1.Selected.Value) > 0 &&
     Len(ComboBox4.Selected.DisplayName)> 0 &&
     Len(TextInput1.Text) > 0 &&
     Len(TextInput2.Text) > 0 &&
     Len(ComboBox4.Selected.Mail) > 0,
     DisplayMode.Edit,
     DisplayMode.Disabled
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    @WarrenBelz solution will work.  But when you start getting a large number of controls to validate against I usually find its easier to set the OnChange events of the controls themselves to increment and decrement a counter of how many controls are empty.  Then set the button to activate if the counter is 0.  It takes a bit of planning, but its much easier to maintain when you get a large number of controls on the screen because it isolates the logic down to each control.

  • Masum172 Profile Picture
    on at

    Hi WarreBellz,

     

    Thank you for your suggestion 🙂

     

    I have tried this and looks as though it likes the formula but nothing happens? The status of the button remains enabled and doesn't change for odd reason not sure!

     

    Masum172_0-1676740792821.png

     

  • Masum172 Profile Picture
    on at

    Hi Pstork1!

     

    Thanks for your suggestion!

     

    Do you mean set an OnChange command for each Combo box & Text Input values and then setting the OnSelect for the button accordingly? how would I accomplish this please.

     

    Thanks for your help so far!

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    Yes, Set an OnChange event for each control that either increments or decrements a variable based on whether it is filled in or deleted.  Then use the variable with the total count to determine whether all the controls are filled in.

     

    Lets say you have 6 controls on the page and in the OnChange event of each control it increments a counter called varCounter each time the control goes from empty to filled in.  When varCounter reaches 6 you make the button active.  If you add a 7th control you set its onChange event the same way and increase the check on the button to 7, but you don't have to change any other control or maintain a complex list of If statements in the button.

  • Pstork1 Profile Picture
    68,717 Most Valuable Professional on at

    Just to follow up on this.  Here is a sample of the code I use.

    In App.OnStart

     

     

    Set(requiredFields,<<Number of Fields Required>>);
    Set(targetRequireds,<<Target fields not empty at start>>); 

     

     

    In each required control's OnSelect

     

    Set(currentValue1,Len(Self.Text))

     

    In each required control's OnChange

     

     

    If((currentValue1=0&&Len(Self.Text)>0),Set(targetRequireds,Sum(targetRequireds,1)));
    If((currentValue1>0&&Len(Self.Text)=0),Set(targetRequireds,Sum(targetRequireds,-1)));
    

     

     

    In DisplayMode on Submit Button

     

     

    If(targetRequireds >= requiredFields, DisplayMode.Edit, DisplayMode.Disabled)

     

     

     

    If a Required Control is changed from blank to filled in the targetRequireds will be incremented. If changed from filled in to blank targetRequireds will be decremented. Otherwise the count won't change. There is a CurrentValue# for each required control.

  • Masum172 Profile Picture
    on at

    Thank you all for your suggestions 🙂

     

    Unfortunetaly, I haven't managed to get far with this after trying WarreBellz solution, it accepts the formula fine but buttons are still enabled so not exactly sure what the code is doing. I am really new to Power Apps so apologies If I do ask questions which may sound stupid (This is my first app)

     

    @Pstork1 Thanks, I'm not sure exactly where to start with this one and don't want to risk breaking any controls in my app as will end up staying up a whole night to try and figure out where it went wrong! 😞

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard