Copy link to clipboard
Copied
Hello,
I am making a form with required fields. I would like the form to do the following when the submit button is pushed:
1: check to make sure all required fields are filled out.
2: Once form is read only, send email with subject as one of the fields
I have been researching this for weeks and have been trying lots of options, but haven't found one that works. Any help is appreciated! Thanks!
Copy link to clipboard
Copied
You can use this code to achieve it:
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f!=null && f.type!="button" && f.required && f.valueAsString==f.defaultValue) {
emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("You must fill in the following fields:\n" + emptyFields.join("\n"));
} else {
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f!=null) f.readonly = true;
}
var subjectLine = this.getField("Text1").valueAsString;
var msgBody = "This is the message body of the email";
this.mailDoc({cTo: "me@server.com", cSubject: subjectLine, cMsg: msgBody});
}
Copy link to clipboard
Copied
You can use this code to achieve it:
var emptyFields = [];
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f!=null && f.type!="button" && f.required && f.valueAsString==f.defaultValue) {
emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert("You must fill in the following fields:\n" + emptyFields.join("\n"));
} else {
for (var i=0; i<this.numFields; i++) {
var f = this.getField(this.getNthFieldName(i));
if (f!=null) f.readonly = true;
}
var subjectLine = this.getField("Text1").valueAsString;
var msgBody = "This is the message body of the email";
this.mailDoc({cTo: "me@server.com", cSubject: subjectLine, cMsg: msgBody});
}
Copy link to clipboard
Copied
Thanks so much! This worked perfectly!
Copy link to clipboard
Copied
In what way