Hello,
I am working in acrobat, using javascript to try and validate if one out of a group of 4 checkboxes is selected before returning "true" to a variable to mail the pdf.
I am not quite sure where to start with this. Here is my code as it sits..it currently checks for required fields, but I am unsure exactly how to look at a grou of fields to make sure at least one is checked.
var bSuccess = true;
//Populate the subject line with customer and salesperson info
var cSubline = this.getField("Custname").value + " request for inventory, "
+ "Custno: " + this.getField("Custno").value + " "
+ "Salesperson: " + this.getField("Salesman").value;
var msgBody = "Request for inventory form attached.";
var address = "tjoines [at] preciousmetals [dot] com";
//Validate required fields
var requiredFields = new Array(3)
requiredFields[0] = "Salesman";
requiredFields[1] = "Custname";
requiredFields[2] = "Custno";
var alertMsg = new Array(3)
alertMsg[0] = "Please enter the salesperson code for this order.";
alertMsg[1] = "Please enter the Customer name.";
alertMsg[2] = "Please enter the Customer code from CRM.";
var emptyTest = /^\s*$/;
var fieldCount = requiredFields.length
var fld = 0;
for (var i=0; i < fieldCount; i++)
{
fld = this.getField(requiredFields[i]);
if( emptyTest.test(fld.value) ) // if required field is empty
{
bSuccess = false;
app.alert(alertMsg[i],1);
fld.setFocus();
break;
}}
//Validate Inventory Type checkboxes
//Check for validation true or false
if (bSuccess) {
//Send the Order as PDF
this.mailDoc({
bUI: true,
cTo: address,
cSubject: cSubline,
cMsg: msgBody,
cSubmitAs: "PDF"
});
}