Skip to main content

Notifications

Community site session details

Community site session details

Session Id : cJOkBKpGRQDr3KSnkpgKoT
Power Apps - Building Power Apps
Answered

Validate all the required field before submitting a form.

Like (0) ShareShare
ReportReport
Posted on 27 Jul 2023 22:02:36 by 27

I have two forms. They are both connected to different data sources. 

- form 1 is on screen 1

- form 2 is on screen 2

 

On-screen 1, I just want to validate the fields and upon successfully validating the field, I want to navigate to screen 2 (Not submitting form 1). Also, I would like to show all the empty fields just like below:

yashp1196_2-1690495198634.png

 

On-screen 2, I would like to validate form 2 and upon validating, submit form 1 and form 2 together.  

---------------

form 1 is on screen 1

 

yashp1196_0-1690494921389.png

 

form 2 is on screen 2

yashp1196_1-1690494956554.png

 

  • Verified answer
    v-jefferni Profile Picture
    on 01 Aug 2023 at 03:45:15
    Re: Validate all the required field before submitting a form.

    Hi @yashp1196 ,

     

    If not using SubmitForm to validate the form, you will have to set as many variables as the number of Data Cards, validate the form and determine whether navigating to the other screen on the Form's Valid property. If the Form is not valid, it means that there are empty fields in the form. Then Color of controls and Visible of error message Labels will change based on respective variables.

    If(Form1.Valid, Navigate(Screen2),UpdateContext({DC1: DataCard1.Valid, DC2: DataCard2.Valid, DC3: DataCard3.Valid, ...})

     

    Visible of error message Label in Data Card 1

    !DC1

    Data Card 2

    !DC2

    and so on.

     

    BorderColor of DataCardValue1

    If(DC1, Parent.BorderColor, Color.Red)

    BorderColor of DataCardValue2

    If(DC2, Parent.BorderColor, Color.Red)

    and so on.

     

    Best regards,

  • yashp1196 Profile Picture
    27 on 31 Jul 2023 at 16:02:49
    Re: Validate all the required field before submitting a form.

    Thats a good idea @v-jefferni , but i do not want to submit the form on screen 1, because what if the users wants to go back from screen 2 to 1 to fix something. 

  • v-jefferni Profile Picture
    on 31 Jul 2023 at 02:01:03
    Re: Validate all the required field before submitting a form.

    Hi @yashp1196 ,

     

    Since borders and error messages will come up only when you submit the form, you can validate the form first, if it's valid then navigate to screen2, if not, submit form to call out the error message.

     

    OnSelect of the Next button:

    If(EditForm1.Valid, Navigate(Screen2), SubmitForm(EditForm1))

     

    on screen2, validate the form2 first, if it is valid then submit the two forms. But if it's not valid, submit form2 to call out the errors:

    If(Form2.Valid, SubmitForm(Form1);SubmitForm(Form2), SubmitForm(Form2))

     

    Best regards,

     

  • yashp1196 Profile Picture
    27 on 28 Jul 2023 at 17:29:14
    Re: Validate all the required field before submitting a form.

    Form1.valid does not give you the below validation. What I am looking for is showing all the red borders and red messages.

    yashp1196_0-1690565295415.png

     

  • v-jefferni Profile Picture
    on 28 Jul 2023 at 03:09:36
    Re: Validate all the required field before submitting a form.

    Hi @yashp1196 ,

     

    You can simply leverage the Valid property of the Forms:

    vjefferni_0-1690513661573.png

     

    So, you can navigate and submit form based on whether each form is valid.

    If(Form1.Valid, Navigate(Screen2), Notify(...))

    If(Form1.Valid && Form2.Valid, SubmitForm(Form1), SubmitForm(Form2))

     

    Best regards,

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 > Power Apps - Building Power Apps

#1
MS.Ragavendar Profile Picture

MS.Ragavendar 27

#2
mmbr1606 Profile Picture

mmbr1606 14 Super User 2025 Season 1

#3
Michael E. Gernaey Profile Picture

Michael E. Gernaey 13 Super User 2025 Season 1

Overall leaderboard
Loading started