Submit Button: Check Required Fields then Send Read Only File by Email
I have a submit button on the form I'm creating.
1) After researching various examples, I have the following JS set up:
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f= this.getField(this.getNthFieldName(i));
if (f.type!="button" && f.required ) {
if (f.valueAsString==f.defaultValue) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("Error! You must fill in the following fields:\n" + emptyFields.join("\n"));
}
It seems to be working but it still allows the document to be sent by email after clicking OK on the warning window. Any ideas on how to fix that? Ideally, I would like the user to be returned to the form to finish completing the document.
2) Is there a way to send the form in a read only format without changing it for the user? I'm noticing in my tests that when I have the document sent to me, I am able to change the fields. I wouldn't want that to be the case. Ideally, I would like the person receiving the file by email to not be able to change any of the information. Any ideas?
In case it helps, below is the JS I've written for the submit button to email the form:
var cToAddr = "email@email.com";
var cCcAddr = this.getField("DeptEmail").value;
var cSubLine = "CRT Submission";
var cBody = "This Civil Routing Transmittal (CRT) and attached supporting documents are hereby submitted.";
this.mailDoc({bUI: true, cTo: cToAddr, cCc: cCcAddr, cSubject: cSubLine, cMsg: cBody});
Thanks in advance!
