I have 5 textboxes on a screen.
I need all 5 to be filled with data
IF
any one of the five have text in them.
They must complete the other 4 textboxes.
Thanks
Dave
Are these boxes on a form?
no, they are not part of a form
You don't specify the action that will next be taken once the textboxes are filled in but assuming you are either going to save them or move on to the next screen, I would approach this by using a context variable as a counter.
and enabling or disabling that control until the criteria are met.
First, leave a message in the Default property of the textboxes so they are not blank to start with. This is done so that when the user removes the default text, the counter is set back. To do this, highlight all the textbox controls and in the OnChange property. The first time a user puts information in one of the boxes, a message will be sent that all the boxes must be filled.
If(
IsBlank(Self.Text),
UpdateContext({var: var - 1}),
UpdateContext({var: var + 1})
);
If(
var = 1,
Notify(
"All five boxes need to be filled",
NotificationType.Information
)
)
In a save button or next button DisplayMode property
If(var=0 || var=5,Edit,Disabled)
To reset everything in the OnVisible property of the screen and in the Next or a Patch() button,
Reset(TextInput1);
Reset(TextInput2);
Reset(TextInput3);
Reset(TextInput4);
Reset(TextInput5);
UpdateContext({var: 0})
So for your button or whatever you have to move on to next screen and an error message can use this same logic. Just do something like this.
On a Button. DisplayMode property of it. If(textbox1.Text <> "" && textbox2.Text <> "" && Textbox3.Text <> "" && Textbox4.Text <> "" && Textbox5.Text <> "", DisplayMode.Edit,DisplayMode.Disabled)
This makes the button not clickable till all 5 have text in them.
Error message visable property. (textbox1.Text = "" || textbox2.Text = "" || Textbox3.Text = "" || Textbox4.Text = "" || Textbox5.Text = "") || !(textbox1.Text = "" && textbox2.Text = "" && Textbox3.Text = "" && Textbox4.Text = "" && Textbox5.Text = "")
Show the error message if any of the Textboxes are blank unless All the Text Boxes are blank (OR Not 😃 .
User | Count |
---|---|
258 | |
110 | |
90 | |
51 | |
44 |