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

Check for different types of mandatory acrobat fields.

Flash2009
Registered: Sep 7 2009
Posts: 11

Hello,
  
I'm looking for a JavaScript script which will check if 5 different fields in a form are filled in.
My form contains the following 5 mandatory fields.
 
CheckBox field
Variable name : TestCheckBox
 
RadioButton field
Variable name : TestRadioButton
there are 4 radiobuttons in the form, all have the same TestRadioButton variable name.
 
TextField field
Variable name : TestTextField
 
ComboBox field
Variable name : TestComboBox
 
ComboBox with user entry field
Variable name : ComboBoxUserEntry
 
What i want to do is the following.
I need a script which checks if all different 5 fields are filled in.
If one (or more) are not a message like "CheckBox 'TestCheckBox' not filled in" has to be displayed.
 
The script will be invoked when the user clicks on the "Check form" button.
 
Can someone please show me how to build a script like that ?
 
Thanks :-)
  
Flash

My Product Information:
Acrobat Pro 8.1.3, Windows
try67
Expert
Registered: Oct 30 2008
Posts: 2398
How can a check-box be required? Or is it something like "I agree to the terms"?
I was going to suggest a general code to verify text, radio and lists, but if you require custom validation (like a text field that must be filled if a check-box is ticked), then maybe you're better off just doing it manually.
Something like:

var msg = "";
if (getField("text1").value=="")
msg+="You must fill in \"text1\".\n";

// ... etc. for the other fields ...

if (msg=="") app.alert("Everything is fine!",3);
else app.alert(msg);

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com

padobe
Registered: Jun 29 2011
Posts: 10
Hi,

Put all the mandatory fields in one subform and paste the following code in the click event of a button

//Enter name of the SUBFORM
var oNodes = subForm.nodes;
for (var i = 0; i < oNodes.length; i++)
{
//app.alert(oNodes.length);
var node = oNodes.item(i);
if(node.rawValue == "" || node.rawValue == null)
{xfa.host.messageBox("Please enter the value");
xfa.host.setFocus(oNodes.item(i));
break;}
}


try67
Expert
Registered: Oct 30 2008
Posts: 2398
The code above is not for an AcroForm, but for a LiveCycle form.

- AcrobatUsers Community Expert - Contact me personally at try6767 [at] gmail [dot] com
Check out my custom-made scripts website: http://try67.blogspot.com