cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DAVIDPOWELL
Impactful Individual
Impactful Individual

Vaidate if multiple textboxes not filled in

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.

 

DAVIDPOWELL_0-1659730094244.png

 

Thanks

Dave

4 REPLIES 4
zuurg
Resolver I
Resolver I

Are these boxes on a form?  

DAVIDPOWELL
Impactful Individual
Impactful Individual

no, they are not part of a form

Drrickryp
Super User
Super User

@DAVIDPOWELL 

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})

 

 

 

 

 

 

 

cwebb365
Super User
Super User

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 😃

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (2,497)