Skip navigation
Currently Being Moderated

Forms Javascripts

Jul 10, 2012 2:50 PM

Hi, I'm not sure if I should ask this question in this forum or use the Adobe Javascript forum.  I have a form that needs to have a javascript in it.  I have Adobe Acrobat X.  What I need it to do is this:

 

If a user entered a Posted Speed in the Text Field, the Check box for Prima Fascia cannot be selected.  The same goes the other way, if someone checks the Prima Fascia check box, then nothing can be entered into the Posted Speed Text Field. 

 

Is there a javascript that can be used for this?  Thanks for your assistance.

 

Connie Bretes

 
Replies
  • George Johnson
    9,216 posts
    Aug 11, 2002
    Currently Being Moderated
    Jul 10, 2012 3:13 PM   in reply to csb102155

    It would be easiest to set it up so that when the check box is selected, the text field is cleared and becomes readonly, and when it is not selected, it becomes fillable. Would that be OK?

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 16, 2012 8:53 AM   in reply to csb102155

    When a field is read only it can not interact directly by user input. So, you can only have the check box action change the read only property of the text field.

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 16, 2012 11:22 AM   in reply to csb102155

    I would use the "Mouse Up" action for the check box and set the readonly property of the text field based on the value of the check box.

     

    Assuming you are using a single check box field named "ChecBox 1" and text field named "Text1" your mouse up action could be:

     

    if(this.getField(event.target.name).value != "Off") {

    // check box has been selected

    this.getField("Text1").readonly = false;

    } else {

    // check box not selected

    this.getField("Text1").readonly = true;

    // option to clear the field if check box not selected

    this.getField("Text1").value = "";

    }

     

    or

     

    if(this.getField(event.target.name).isBoxChecked(0)) {

    // check box has been selected

    // make RW

    this.getField("Text1").readonly = false;

    } else {

    // check box not selected

    // option to clear the field if check box not selected

    this.resetForm(["Text1"]);

    // make read only

    this.getField("Text1").readonly = true;

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points