Skip to main content
Participant
August 10, 2023
Question

Adobe Form Submit Button not sending email

  • August 10, 2023
  • 1 reply
  • 680 views

I'm working with a form that has fields populate based on a drop-down selection. I'm applying a script to a submit button to validate required fields, but to ignore them if they're hidden. If all of the required visible fields aren't complete the user should get an error message and then be returned to the form suppressing the email. This piece is working. But, now even after the fields have been completed, the email won't generate. Both scripts work separately. But I can't seem to get them to work together. I'm pretty new with JavaScript. Any help would be appreciated. 

var emptyFields = [];
for (var I=0; I<this.numFields; I++) {
var f= this.getField(this.getNthFieldName (i));
if (f.type!=“button” && f.required && f.display!=display.hidden) {
    if (f.valueAsString==f.defaultValue) emptyFields.push(f.name);
}
}
if (emptyFields.length>0) {
app.alert (“Please complete the following fields:\n” + emptyFields.join(“\n”));
}
if (requiredFields.length > 0) {
app.alert(error);
} else {
var notes = “Form:” + getField(“Name”).value;
var name = getField(“Contact”).value;
this.mailDoc({

 

cTo: “Email@email.com”,
cSubject: notes,
cMsg: message text
})}
This topic has been closed for replies.

1 reply

Nesa Nurani
Community Expert
Community Expert
August 10, 2023

You used uppercase 'I' for loop and then used lowercase 'i' in this.getNthFieldName (i).

You are using variable if (requiredFields.length > 0) but it's not declared anywhere also in cMsg: message text.

You're using curly quotes (“ ”), JavaScript requires straight quotes (" ") for strings.

mezgrlardAuthor
Participant
August 10, 2023

Thank you. So I fixed the quotes and capitalization. How would I declare it? 

Nesa Nurani
Community Expert
Community Expert
August 10, 2023

Same as emptyFields.