Expand my Community achievements bar.

How to validate checkboxes?

Avatar

Former Community Member

Hi All, may I ask your advice how to implement following items?

Software: Adobe LiveCycle Designer ES4

Usage: Create PDF form and allow user to save inputted records (with LiveCycle Server or Acrobat 9 Pro)

I tried to add three checkboxes for the test, and I would make sure:

1) Users should selected at least one checkbox before save.

2) If user selected checkbox 1, the form should not allow user to select checkbox 2 and 3.

3) User is allowed to select both checkbox 2 & 3, but not vice versa.

How can I add the validation rule for above checkboxes (if JavaScript is required, how to add it?),

Besides, if some coding is required, could you please provide some samples to me for follow-up?

e.g.

if (CheckBox1.rawValue == "0" && CheckBox2.rawValue == "0" && CheckBox3.rawValue == "0")

{

alert('Please select at least one record')

}

else if

{

  //I don't know >///<

}

Thank you very much (^人^)


1 Reply

Avatar

Level 10

Hi, first if you dont want the user to choose more than one option if the checkbox 1 is chosen, you will have to put scripts in all 3 checkboxes to verify if your conditions are followed as you want.

CheckBox1:change::event

if (CheckBox2.rawValue == 1 || CheckBox3.rawValue == 1){

     CheckBox2.rawValue = 0;

     CheckBox3.rawValue = 0;

}

CheckBox2:change::event  && CheckBox3:change::event

if (CheckBox1.rawValue == 1 && this.rawValue == 1){

     CheckBox1.rawValue = 0;

}