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 / Disable "Submit" butto...
Power Apps
Answered

Disable "Submit" button until EITHER text box or choice field is populated.

(0) ShareShare
ReportReport
Posted on by

 

I have a form that has two fields: a text field and a combo-box

 

jharville_0-1627517950199.png

 

 

My goal: If either of the two fields is populated, I want the "Book" button to be enabled and clickable to submit the form. If neither of the two fields are populated, I want the "Book" button to be disabled.

 

Here's the caveat: The text box checks to see if the email address entered is in the correct format. If it is not in the correct format, the border of the box turns red and our boolean variable, 'Label33' is assigned "False". If it is in the correct format, 'Label33' is assigned "True" and the border of the box turns blue        ...        The conditional assignment of "True" or "False" on that "Label33" is already functional. But if the text box is populated with an incorrectly formatted email ('Label33' is "False"), I don't want the "Book" button to be clickable. 

 

I'm messing around with the DisplayMode properties of the combo-box, but have had no luck so far:

 

jharville_1-1627518116599.png

 

Would anybody be able to provide some help? 

 

Thank you so much,

 

Justin

 

Categories:
I have the same question (0)
  • v-xiaochen-msft Profile Picture
    on at

    Hi @jharville ,

     

    I did a simple demo for you.

    1\ I have a textinput control 'TextInput1' and set its BorderColor property to:

    If(IsBlank(TextInput1.Text),Blue,IsMatch(TextInput1.Text,"^([0-9]|[0-9]\.\d+|[1-9][0-9]|[1-9][0-9]\.\d+|100)$"),Blue,Red)

    // If the value is not a decimal within 0-100 or is not blank, the border color is red.

    vxiaochenmsft_0-1627522755980.png

    vxiaochenmsft_1-1627522764568.png

    vxiaochenmsft_2-1627522773042.png

     

    2\ Add a combo box control 'ComboBox1'

     

    3\ Add a button control and set its DisplayMode property to:

    If(TextInput1.BorderColor=Red,DisplayMode.Disabled,!IsBlank(TextInput1.Text)||(CountRows(ComboBox1.SelectedItems)=Blank()||CountRows(ComboBox1.SelectedItems)=0),Edit)

     

    4\ The result is as follows:

    vxiaochenmsft_3-1627522826939.png

     

    vxiaochenmsft_4-1627522836438.png

    vxiaochenmsft_5-1627522846535.png

    vxiaochenmsft_6-1627522857760.png

    vxiaochenmsft_7-1627522870236.png

     

     

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

     

     

     

     

     

  • jharville Profile Picture
    on at

    Hi Wearsky! @v-xiaochen-msft 

     

    I really do appreciate the comment, I moved your code to my app and there are no errors, but it isn't achieving the desired function. 

     

    jharville_0-1627527573442.png

    ^^ when the text input is blank, but the combo-box is populated, the button is still disabled. 

     

    Everything else works except that scenario I listed above. We are getting very close, but not quite there.

     

    Here is the code in the DisplayMode of the Book button. It's the exact same as yours, except I switched out your "TextInput1" for "TextInput2" since my text input was called "TextInput2":

    jharville_0-1627527877714.png

     

     

     

  • Verified answer
    v-xiaochen-msft Profile Picture
    on at

    Hi @jharville ,

     

    Please try this formula:

    If(TextInput1.BorderColor=Red&&(CountRows(ComboBox1.SelectedItems)=Blank()||CountRows(ComboBox1.SelectedItems)=0),DisplayMode.Disabled,IsBlank(TextInput1.Text)&&(CountRows(ComboBox1.SelectedItems)=Blank()||CountRows(ComboBox1.SelectedItems)=0),Disabled,!IsBlank(TextInput1.Text)||(CountRows(ComboBox1.SelectedItems)=Blank()||CountRows(ComboBox1.SelectedItems)=0),Edit)

     

    Best Regards,
    Wearsky
    If my post helps, then please consider Accept it as the solution to help others. Thanks.

  • jharville Profile Picture
    on at

    @v-xiaochen-msft 

     

    I appreciate you so much, thank you for the help. This worked exactly how I wanted it to. 

  • jharville Profile Picture
    on at

    Hi Wearsky, I actually have one last question. @v-xiaochen-msft 

     

    If I want to do the same thing as before (only require either the text input or combo-box to be populated) for the "Book" button to be enabled ... but require the Subject to be populated at all times as well, what would the code be?

    jharville_1-1627680223547.png

     

    Thank you so much, I apologize for the inconvenience

     

     

     

     

     

  • jharville Profile Picture
    on at

    @v-xiaochen-msft 

     

    I actually figured out the new modified code I need to include the "Subject" in the new condition:

    If(
     IsBlank(TextSubject.Text) || TextInput2.BorderColor = Red && (CountRows(ComboBox1.SelectedItems) = Blank() || CountRows(ComboBox1.SelectedItems) = 0),
     DisplayMode.Disabled,
     IsBlank(TextSubject.Text) || IsBlank(TextInput2.Text) && (CountRows(ComboBox1.SelectedItems) = Blank() || CountRows(ComboBox1.SelectedItems) = 0),
     Disabled,
     !IsBlank(TextInput2.Text) || (CountRows(ComboBox1.SelectedItems) = Blank() || CountRows(ComboBox1.SelectedItems) = 0),
     Edit,
     !IsBlank(TextSubject.Text) || !IsBlank(TextInput2.Text) || (CountRows(ComboBox1.SelectedItems) = Blank() || CountRows(ComboBox1.SelectedItems) = 0),
     Edit
    )

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