I have modified code from here:
http://www.acrobatusers.com/forums/aucbb/viewtopic.php?id=13246
I have set the Text field and dropdown to "User Entered - Required".
I have a textbox and dropdown field that I need to check for null data.
I pasted the code on my button click event:
// These are the required fields on the form.
// Populate array with their names.
var requiredFields = new Array(2);
requiredFields[0] = "TextField1_4";
requiredFields[1] = "DropDownList2_4";
// These are the alert messages shown when a required field is empty.
// Populate array with messages.
// Make sure there's one message for each required field.
var alertMsg = new Array(2);
alertMsg[0] = "Enter device name.";
alertMsg[1] = "Specify Rendering Intent.";
// Regular expression. It means start at beginning of string, look for any single
// white space char, one or more times, to the end of the string.
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
{
app.alert(alertMsg[i]);
fld.setFocus();
break;
}
}
I do not get any popup mesages.