I have a form that has three fields: a text field for the "Subject", a text field for "Emails", and a combo-box for "Internal Users"
My goal: If the Subject is populated AND either of the two other fields ("Emails" or "Internal Users") are populated, I want the "Book" button to be enabled and clickable to submit the form. If this condition isn't met, I want the "Book" button to be disabled. So if the "Subject" field isn't populated, but one of the two other fields is populated, the "Book" button should not be active.
My current code (in the DisplayMode of the "Book" button) currently enables the button if one of the two fields ("Emails" or "Internal Users") is populated:
If(TextInput2.BorderColor=Red&&(CountRows(ComboBox1.SelectedItems)=Blank()||CountRows(ComboBox1.SelectedItems)=0),DisplayMode.Disabled,IsBlank(TextInput2.Text)&&(CountRows(ComboBox1.SelectedItems)=Blank()||CountRows(ComboBox1.SelectedItems)=0),Disabled,!IsBlank(TextInput2.Text)||(CountRows(ComboBox1.SelectedItems)=Blank()||CountRows(ComboBox1.SelectedItems)=0),Edit)
.. but I want to add an extra piece of code that requires the "Subject" to be populated, and then looks to the current condition of my code I attached above (see if one of the "Emails" or "Internal Users" fields are populated to enable the "Book" button).
(Background of my code: My "Emails" 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)
Would anybody be able to provide help in adding in that extra condition?
Thank you so much,
Justin
Hi @jharville ,
Since you have solved your issue, I would close this thread so that other community members who stuck with the same question can directly see your solution.
Best regards,
Allen
That is not what happens in my sample. I'm not sure how your code is different from what I supplied, but something isn't in the right place or with the right name. The code you modified below is far more complex than it needs to be. The following is with my code and you can see that the button is only live if a Subject line and one of the other controls is populated.
I actually modified my existing code and got it to work.
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
)
Thank you so much for your help though, I did learn something new and I really appreciate it! 🙂
I think I found the issue with the code. When you only populate the 'Emails" and nothing else, the "Book" button is not enabled ... which is good.
And when you add in populating the "Subject" text input, the "Book" button is enabled ... which is also good!
But here's the issue. When you take out the 'Emails' text input, and leave the Subject ... the "Book" button is still enabled, when it should be disabled.
What would we have to add to our existing code in the DisplayMode to take into account that change of removing the population of a field and having the "Book" button reflect that change?
If its just the hint text and not the text or default it should work fine. See the screenshot below.
If I understand correctly, would I not be able to have any Hint Text if I want your method to work?
Double check to make sure that the subject text field is actually empty and does not contain the prompt you are displaying in that box. I tested it in a small app and it works as you requested. If either the subject box or (either the email or combobox are not filled in) the button will be disabled. Something about your setup is not showing the Subject box as blank.
For your code you don't combine it with your code. It is a complete replacement for the Displaymode property of the button.
Thank you for the reply. How would I combine that piece of code with the existing code that I have?
My current code works to enable the "Book" button if either the "Emails" or "Internal Users" is populated, but doesn't have a condition regarding the "Subject" text input. I need to make sure the "Subject" is populated first and foremost, and then check to see if either of the "Emails" or "Internal Users" is populated to enable the "Book" button.
I tested your code with just itself (took out my code), and it didn't achieve the desired function:
^^Subject is empty, but one of the two fields ("Emails" or "Internal Users") is populated. But since "Subject" is empty, the "Book" button shouldn't be active.
^^Subject is empty, but one of the two fields ("Emails" or "Internal Users") is populated. But since "Subject" is empty, the "Book" button shouldn't be active.
This code in Displaymode should do what you want. Just adjust the control names to match yours.
If(IsBlank(txtSubject.Text) || (IsBlank(txtEmail.Text) && IsBlank(ComboBox1.SelectedItems)),DisplayMode.Disabled, DisplayMode.Edit)
WarrenBelz
223
Most Valuable Professional
MS.Ragavendar
110
Michael E. Gernaey
89
Super User 2025 Season 1