These forums are now Read Only. If you have an Acrobat question, ask questions and get help from one of our experts.

Make a pulldown required if another text field is entered

adjmcloon
Registered: Jan 8 2010
Posts: 13

Hello,
 
I have been researching this. I am using a custom submit button that calls a javascript in order to determine who to email and to check validation on some fields.
 
I have description and "commission level" fields in my document (12 of them as line items). If one of my salespeople enters text into the description field, I want the corresponding commission field to become required. My fields are named description.1 and commlevel.1, etc. up to 12
 
So far I have tried to use a validation script like this. For instance, this is the validation code for my first description field. I am trying to make the corresponding commlevel.0 field required.
 
var rgEmptyTest = /^\s*$/;
if(rgEmptyTest.test(event.value)){ // Field is empty, make other fields not required
this.getField("Commlevel.0").required = false;
}else{
// Field is not empty, make other fields reqired
this.getField("Commlevel.0").required = true;}
 
I am getting hung up because I am using my own submit button. I can't seem to get it to validate. I would very much appreciate any suggestions on how to handle this. Thanks!

My Product Information:
Acrobat Pro 9.0, Windows
adjmcloon
Registered: Jan 8 2010
Posts: 13
I thought it might be just as easy to test if a field is not empty, and then just set a variable and call an alert box to prompt the user to fill in the commission box. Here is all of the code for my submit button

//Get Order form variable values
var trade = this.getField("Trade").value;
var desc = this.getField("DESCRIPTIONRow1").value;
var total = this.getField("Total").value;
var ckref = this.getField("Nameofref").value;
var bSuccess = true;
var needscomm = true;

//Validate required fields
var requiredFields = new Array(2)
requiredFields[1] = "SP";
requiredFields[2] = "AdCode";

var alertMsg = new Array(2)
alertMsg[1] = "Please enter the salesperson code for this order.";
alertMsg[2] = "Please enter the ad code for this order.";

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;
}}

//PCI sheet processing
if (total > 0.00) {
address = "orders [at] blah [dot] com"
}
else if (total == "0.00") {
address = "user2 [at] blah [dot] com"
}
else if (desc != "") {
address = "orders [at] blah [dot] com";
}//Check for Referral
if (ckref == "") {
refcc = "";
}
else if (ckref != "") {
refcc = "user1 [at] blah [dot] com";
}//Populate the subject line with customer and salesperson info
var cSubline = this.getField("CustomerName").value + " order, "
+ "Custno: " + this.getField("CustNo").value + " "
+ "Salesperson: " + this.getField("Salesperson").value;
var msgBody = "Press Send to submit your order for processing!";

//Check for validation true or false
if (bSuccess) {
//Send the Order as PDF
this.mailDoc({
bUI: true,
cTo: address,
cCc: refcc,
cSubject: cSubline,
cMsg: msgBody,
cSubmitAs: "PDF"
});
}