Using individual field validation checks on the web may discourage users because on submission they only get the failure message from the first field to fail its validation, they may have to make repeated changes and submit a form several times before they get it all right. Repeated failed submissions also involve unnecessary network and server traffic and can be slow.
There is a 'third way' that uses @Formula validation but presents all failure messages at once and displays them attractively too! You can do it all in one field but I prefer to use two.
Add a hidden, computed-for-display field at the top of the form and call it 'ValidationMsg', it can be a shared field if you prefer. The contents of the field should be something like:
"Your document can't be saved"
+ "Click go back"
+ " then add the missing details and re-submit.
+ "Click here if you want to abandon your edits"
In the last line 'db' is the name of another computed-for-display field above the 'ValidationMsg' field in the form. 'db' should evaluate to a URL suitable for users to 'jump back into' the web site if they give up their submission, I just re-open the database with the formula:
This 'ValidationMsg' field can be used with validation formula in each field simply by adding the field name to the end of your @Failure string ... but if you want to show all validation failures together, remove validation formula from all editable fields in the form and add another field at the bottom of the form, make it a hidden, editable field and call it 'ValidationCheck'.
This 'ValidationCheck' field is where all the validation happens so you might need lots of @Formula language! The example below does two things really. First, it gets rid of some editable fields used in the form but which don't need to be saved. Second, it selectively adds failure messages to an initial string (x). If the final message (err) is the same as it was at the beginning (if err = x), then we know there are no validation failures and the submission can succeed. If there are errors we add the ValidationMsg text to our error messages, along with some HTML to make it look nice and present it all to the user. The 'ValidationCheck' field Input Validation event might contain a formula like this:
x:="You need to enter
- contributor's full name ";"")+
- a valid email address ("+
@ValidateInternetAddress([Address821];Email)+") or phone number ";"")+
- a longer subject ")+
- more text ")+
- just one attached file per message ";"")+
- your attached file is too big ("+@Text(files)+"K) ";"");
@If(namereq & !(@Length(Name)>7 & @Contains(Name;" "));"
@If(namereq & !(@ValidateInternetAddress([Address821];Email)="" | Phone!="");
@If(@Length(Subject)>7; ""; "