cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
NigelP
Kudo Kingpin
Kudo Kingpin

Validating a New Form (Form Mode = FormMode.New)

Hi

 

Whilst there is a lot of documentation on validating forms when they are in Edit Mode, there does not seem to be alot of documentation about validating a form when in New Mode.

 

I  would like to make sure all of the fields marked as "Required" have actually got something in them and the entered value is acually the right type (integer, string etc).  Each card on the form has got "Required" set to true.

 

I would like to validate the form before I submit it. (Form.Valid does not seem to work for forms in Form.Mode = FormMode.New) 

 

Have i missed something ?

 

Regards

 

Nigel

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @NigelP ,

Could you please share a bit more about your scenario?

Do you want to validate a New Form using the Form.Valid formula?

 

Based on the issue that you mentioned, I have made a test on my side, and don't have the issue that you mentioned. The Form.Valid formula works well with All Required fields within my New Form. On my side, I set the OnSelect property of the "Submit" button to following:

If(
EditForm1.Valid,
SubmitForm(EditForm1),
Notify("There are some invalid values in your Edit form", NotificationType.Error)
)

 

Please make sure you have set the Required property to true for all fields in your Edit form, and provide values for these Required fields when you test the Form.Valid formula.

 

Please consider take a try to re-create a new app based on your data source, set the OnSelect property of the "Submit" button to following:

If(
    YourEditForm.Valid, 
    SubmitForm(YourEditForm), 
    Notify("There are some invalid values in your Edit form", NotificationType.Error)
)

 

In addition, as an alternative solution, please also take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

If(
   !IsBlank(DataCardValue1.Text) && !IsBlank(DataCardValue2.Text) && !IsBlank(DataCardValue3.Selected.Value) && ... ,
   SubmitForm(YourEditForm),
   Notify("There are some invalid values in your Edit form", NotificationType.Error)
)

Note: The DataCardValue1, DataCardValue2, DataCardValue3, ... represents the Input controls in your Edit form.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-xida-msft 

 

I will try and explain more what I am going to achieve....

 

If I have a form which is in Edit Mode, then the Valid Property of the Form continuously updates (true / False / True etc) as I update fields.

 

If I take the same form and put it into New Mode  (New_Form(MyForm)) the Valid proprty does not continuously update as I enter the fields.

 

I can reproduce this behaviour by inserting a Label above the form and setting its Text property to MyForm.Valid and observing it when the form is in Edit mode and I am changing fields and then again when it is in New Mode.

 

Regards

 

Nigel

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,355)