I have an app that has a form which is based on a SharePoint list. I have a button that performs the action SubmitForm:
All is fine but if the form has not been completed with all 'required' fields the form submits with an error message. How do I prevent the submit from happening if all the required fields are not complete?
You can can use the Display mode property of the Submit button to do what you require. If DataCardValue2, 6 and 9 were required, then the formula would be
If(IsBlank(DataCardValue2) || IsBlank(DataCardValue6) || IsBlank(DataCardValue9), Disabled, Edit)
Then unless there was data in those three controls, the user could not successfully activate the Submit button.
As an alternative, you could also hide the Submit button by putting a similar formula into its OnVisible property. In this case, all three values would have to hold data for the formula to reduce to true and Unhide the button.
!IsBlank(DataCardValue2) && !IsBlank(DataCardValue6) && !IsBlank(DataCardValue9)
If this answers your question, please mark the thread as solved.
I agree with your thoughts and have faced the same problem. We use the EditForm.Valid method to check if the form is valid before submitting. We then use the !Parent.Valid on the asterisk in the cards to show which fields still have to be completed before allowing the submit.
Please see below video that discusses this in more detail.
Dawid van Heerden
Follow on Twitter: @davestechtips
Subscribe to YouTube: https://www.youtube.com/davestechtips?sub_confirmation=1
**If you found this reply helpful, please mark this as the answer to close the topic and make it easier to find for other people with similar questions. AND we get points for it 😉
Fill out a quick form to claim your user group badge now!
Find out where you can attend!
Features releasing from October 2019 through March 2020
Learn how to build the business apps that you need.