All,

 

I’m a complete noob with javascript, and am wracking my brain on this one.  Have a form (using Acrobat Pro X) with two check boxes that need to influence a text box. I know how to have a single check box influence a text box, but am unsure how to have two boxes influence the same text box.

 

If both are checked, text box is not required. (In this instance box is checked by default.)

 

If either check box is unchecked, text box is not required.

 

If both are unchecked, text box is required.

 

Help?

|||

Required in what way? Some people use this to mean required before the form can be saved or printed, or proceeding with filling-in other fields. A field has a required property that you can set to prevent a form from being submitted until all required fields have a value. Is this what you mean?

|||

Mr. Johnson,

It appears you may save me yet again today. Required as in may not be submitted without the field being completed, if the parameters aren’t met. I certainly would like the end-user to be able to save the document while they’re working on it (it’s a rather large application).

Crystal

|||

OK, the following code for the Mouse Up event of the check boxes assumes the check boxes are named “cb1″ and “cb2″, and the text box is named “text1″. Adjust to suit your form:

 

// Mouse Up script for cb1
(function () {
    var f1 = getField("text1");
    var f2 = getField("cb2");
    f1.required = (event.target.value === "Off" && f2.value === "Off") ? true : false;
})();

 

 

// Mouse Up script for cb2
(function () {
    var f1 = getField("text1");
    var f2 = getField("cb1");
    f1.required = (event.target.value === "Off" && f2.value === "Off") ? true : false;
})();

|||

Mr. Johnson,

 

That was absolutely the solution I neeed. Thanks again!

 

Crystal

|||

Glad to know it’s working. FWIW, that one line could be simplified to just:

 

f1.required = (event.target.value === "Off" && f2.value === "Off");

Related posts:

  1. Text disappear after pasting
  2. PM 6.5 – Is there an auto text box width?
  3. Center Text Vertically
  4. connecting selection of radio button to a text or numeric field
  5. Swf text formatting error, possible swz import issue.

Related posts brought to you by Yet Another Related Posts Plugin.

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2012 free icons download Suffusion theme by Sayontan Sinha

Featuring Recent Posts WordPress Widget development by YD