Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
5

Adobe Form Submit Button not sending email

New Here ,
Aug 09, 2023 Aug 09, 2023

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
})}
TOPICS
How to , JavaScript , PDF forms
703
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2023 Aug 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 10, 2023 Aug 10, 2023

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 10, 2023 Aug 10, 2023
LATEST

Same as emptyFields.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines