I'm trying to add a conditional confirmation message to the form.
The requirements are:
1. Attachments are optional.
2. On submit, required fields validation should happen without prompting the user about the attachment. -- The second part of this requirement (in italic) is a low priority and may be compromised.
3. If all required fields are filled out and no attachment is provided, on submit, prompt the user to confirm that they would like to submit the form without an attachment.
4. If OK, submit the form.
5. If Cancel, return to the form without submitting.
6. If attachment is provided at the time of submission, no prompt for confirmation is needed.
A couple things I've tried so far:
var attTable = document.getElementById(document.querySelector('[id^="idAttachmentsTable"]').id);
var attRow = document.getElementById(document.querySelector('[id^="idAttachmentsRow"]').id);
// No attachments
if (attTable != null && attTable.rows.length == 0)
return confirm("Would you like to submit this without a resignation letter?");
>> The issue with this approach was that it submitted the form even when the user clicked Cancel on the confirmation message instead of taking the user back to the form.
2. Set the button to Save and Submit and add a Confirmation Message ("Would you like to....?") to the button.
>> The issues with this approach was that it prompts the user even when they provided attachment(s).