I have a form that has two fields: a text field and a combo-box
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:
Would anybody be able to provide some help?
Thank you so much,
Justin
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
)
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?
Thank you so much, I apologize for the inconvenience
I appreciate you so much, thank you for the help. This worked exactly how I wanted it to.
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.
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.
^^ 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":
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.
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:
Best Regards,
Wearsky
If my post helps, then please consider Accept it as the solution to help others. Thanks.
WarrenBelz
146,743
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
66,079
Most Valuable Professional