@harryr You can do this by counting the number of attachments, see my example below:
If Witness equals yes then there must be at least 1 attachment
Validation rule: Witness=="Yes"&&GetNumberOfAttachments("nf-form-input5")<1
JS: function GetNumberOfAttachments(attCtrlClassName){
return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow")[0].id)).data('controlid'))};
Thanks both.
I did manage to get this working using a mixture of other posts and muddling through it.
Step 1. Put this function in the custom JavaScript section in the Settings window.
function getNumberOfAttachments(attCtrlClassName){
return NWF.FormFiller.Attachments.GetAttachedFilesCount(NWF.FormFiller.Functions.GetFillerDivObjectForControl(NWF$("#"+NWF$("." + attCtrlClassName + " .nf-attachmentsRow")[0].id)).data("controlid"));
}
2. Then on the attachments control, I put in a validation rule that looks at two fields and checks if either (or) has matched a specific value for each:
or(greaterThanOrEqual(DepartmentsInvolved,2), or(greaterThanOrEqual(TotalProjectTeam2,5)) ) && getNumberOfAttachments("nf-form-input") <1
The above condition checks if field:DepartmentsInvolved is more than or equal to 2 or if field:TotalProjectTeam2 is greater than or equal to 5.
Apologies for not crediting the other posts but it was a mish mash of multiple browser tabs and a few nights sleep since then 🙂
Thanks for all the support on this.
I hope this helps someone else. Basically, you can reuse that JavaScript as it is and then assign a rule to the attachments control to check for field values.