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

Field Validation in another submit button?

New Here ,
Mar 19, 2019 Mar 19, 2019

Hi I have submit form button which validates all the required fields when submitting the overall form. (Im using acrobat pro 11)

However there are parts of the form which need to be sent to line manager for approval.

So i have another button that states "Submit for manager approval" i want this button to validate individual fields that i can input to make sure they are not empty before they send to the line manager for approval.

I've got some JavaScipt on this button which opens up an email pop up so they can enter their Line manager address:

What can i add to the following to make sure individuals fields are not empty before they can submit this:

the field names are Name, Employee Number and date.

JavaScript:
// Set the subject and body text for the email message
var cSubLine = "SPIC Form Approval required"
var cBody = "This form requires your review and approval"

// Send the entire PDF as a file attachment on an email
this.mailDoc({bUI: true, cSubject: cSubLine, cMsg: cBody});

Much appreciated.

Kuium

TOPICS
PDF forms
2.2K
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
1 ACCEPTED SOLUTION
Community Expert ,
Mar 19, 2019 Mar 19, 2019

The basic code to do that is this:

if (this.getField("FieldName").valueAsString==this.getField("FieldName").defaultValue) {

     app.alert("You must first fill in FieldName.");

} else {

     // submit the form

}

You can either create multiple such if-else statements for each field, or you could use an array with all the fields' names in it and a for-loop to iterate over all of them.

View solution in original post

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 ,
Mar 19, 2019 Mar 19, 2019

The basic code to do that is this:

if (this.getField("FieldName").valueAsString==this.getField("FieldName").defaultValue) {

     app.alert("You must first fill in FieldName.");

} else {

     // submit the form

}

You can either create multiple such if-else statements for each field, or you could use an array with all the fields' names in it and a for-loop to iterate over all of them.

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 ,
Mar 19, 2019 Mar 19, 2019

Hi thanks so much,

Apologies beginner JavaScript user here.

Here is the code I have:

All working

if (this.getField("Name print").valueAsString==this.getField("Name print").defaultValue) {
     app.alert("You must first fill in Name field.");
} else if (this.getField("Job title").valueAsString==this.getField("Job title").defaultValue) {
    app.alert("You must first fill in Job field.");

} else {

// Submit form
var cSubLine = "SPIC Form Approval required"
var cBody = "This form requires your review and approval"

// Send the entire PDF as a file attachment on an email
this.mailDoc({bUI: true, cSubject: cSubLine, cMsg: cBody});
}

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 ,
Mar 19, 2019 Mar 19, 2019
LATEST

Yeah, that should work.

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