Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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});
}
Copy link to clipboard
Copied
Yeah, that should work.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more