Forum Moderators: open

Message Too Old, No Replies

Conditionally "required" form fields

         

dhiggerdhigger

12:01 pm on Nov 29, 2007 (gmt 0)

10+ Year Member



I need a form field to be "required", but only if a particular choice is made from another field (a drop down list).

How can I reference the contents of the drop-down field in a conditional statement?

Thanks

dhiggerdhigger

1:12 pm on Nov 29, 2007 (gmt 0)

10+ Year Member



Figured it out. Good job, because I forgot to mention, I am using javascript in a PDF form, not a HTML form!

Here's what worked for me:

The drop down list is named choices
The text field to be changed is called description
"choice2" is the Export Value of the second drop-down list choice


var choiceMade = this.getField("choices").value;
var descr = this.getField("description");
if(choiceMade == "choice2"){
descr.required = true;
// change the text too if you like
//descr.value = "text text text";
}

I put this as a Action when the user moves focus away from the drop down list (onBlur).

Dave