Skip to main content

Notifications

Community site session details
Power Apps - Building Power Apps
Answered

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

Like (0) ShareShare
ReportReport
Posted on 29 Jul 2021 00:26:29 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

 

  • jharville Profile Picture
    on 03 Aug 2021 at 00:56:44
    Re: Disable "Submit" button until EITHER text box or choice field is populated.

    @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
    )
  • jharville Profile Picture
    on 30 Jul 2021 at 21:24:16
    Re: Disable "Submit" button until EITHER text box or choice field is populated.

    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 29 Jul 2021 at 03:13:00
    Re: Disable "Submit" button until EITHER text box or choice field is populated.

    @v-xiaochen-msft 

     

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

  • Verified answer
    v-xiaochen-msft Profile Picture
    on 29 Jul 2021 at 03:09:07
    Re: Disable "Submit" button until EITHER text box or choice field is populated.

    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 29 Jul 2021 at 02:51:03
    Re: Disable "Submit" button until EITHER text box or choice field is populated.

    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

     

     

     

  • v-xiaochen-msft Profile Picture
    on 29 Jul 2021 at 01:41:27
    Re: Disable "Submit" button until EITHER text box or choice field is populated.

    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.

     

     

     

     

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,743 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,079 Most Valuable Professional

Leaderboard