Adobe Acrobat JavaScript Validation Test for 3 PDF Fields

Enflow
Enflow used Ask the Experts™
on
Adobe Acrobat JavaScript Validation Code Test for 3 PDF Fill In Fields

Have One Text Field - Name: HH
Have Second Text Field Name: SG
Have One Checkbox Field Name:  AG

WANT:
Only Allow checking of Checkbox  -  IF  HH  text box AND  SG text boxes have values in them...
Other wise no checking of the checkbox AG
Not sure WHAT is correct event - for checkbox - MouseUP - DN for best action results... ?????

IF Check in Checkbox is allowed after test (both HH and SG have values) then pop msg saying --- "allowed"
IF Check is NOT allowed after test then pop msg saying "not allowed"

Code So Far Not Working and Not Complete:

if (this.getField("HH").value != "") and (this.getfield("SG").value != "") {
    if (this.getField("AG").value != "Off") {
       app.alert("By Checking This Required CheckBox You Have Agreed", 3);                                                                        
                                                                       }
ELSE {
       app.alert("Type In your Print Name and Signature Name FIRST ... \n \n – Before Clicking The I Certify Checkbox", 3);  
        {
                                                                                                                              }
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
leakim971Multitechnician
Top Expert 2014

Commented:
you may use this for both onblur event of the textbox :
if (this.getField("HH").value == "" || this.getfield("SG").value == "") {
    this.getField("AG").readonly = true;
    this.getField("AG").value = "Off";
}
else {
    this.getField("AG").readonly = false;
}

Open in new window


and add the following when click on the checkbox and :
app.alert("By Checking This Required CheckBox You Have Agreed", 3); 

Open in new window

Author

Commented:
Hi leakim971...

nice to work with you again...

I put the first code in HH and SG textboxes blur events

and the put the second code in the mouse down of the AG checkbox

this LOOKS logical but what happens is that ONCE the AG is read only the code EVEN if i have values in HH and values in SG and on EXIT (blur) the
read only state of the checkbox is NOT changed ...

but i agree your code should this.getField("AG").readonly = false;    --- but it does not --- color me confused AT Adobe ?
leakim971Multitechnician
Top Expert 2014

Commented:
remove line 3 and the code on AG, do the readonly stuff work fine ?
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

Author

Commented:
removed the third line of code from BOTH textboxes HH and SG... code in onBlur now FOR BOTH is

if (this.getField("HH").value == "" || this.getfield("SG").value == "") {
    this.getField("AG").readonly = true;
}
else {
    this.getField("AG").readonly = false;
}

removed all the code from AG checkbox but that was only an alert JS...

still once checkbox has read only put on it by the code then THAT'S IT --- no undoing the read only... ???

if i start NEW (uncheck read only and remove all data from textboxes)  i can check or uncheck the AG text box if i do not enter either text box... but once i enter either Textbox or Both then its read only on CBox and nothing changes that... ??
and nothing undoes it... ??

Still after i run the code  and it changes checkbox read only false

Author

Commented:
'Leak...

Just a thought... ONLY to add to the conversation...

If either or both HH and SG are null/empty/"" when the user clicks in the AG field then it pops a msg saying fill in HH & SG BOTH before trying to click in this Checkbox... and does not allow a check in that box

but if both HH & SG are full then it allows a check mark in the checkbox and pops a message saying yes you have correctly signed this pdf

I am not good with JS -- so i am not sure how to write this but is this not more simple ???

I do not care about the user clicking on Checkbox last or second or first... so ??

Just a thought... only a thought ??
leakim971Multitechnician
Top Expert 2014

Commented:
I'm at home and don't have Acrobat here, I will check tomorrow morning
Multitechnician
Top Expert 2014
Commented:
this is just a syntax error, this.getfield("SG") instead this.getField("SG"), please not the "f" is upper case :
if (this.getField("HH").value == "" || this.getField("SG").value == "") {
    this.getField("AG").readonly = true;
    this.getField("AG").value = "Off";
}
else {
    this.getField("AG").readonly = false;
}

Open in new window

Author

Commented:
Thanks 'Leak...

JS Working Now... I will be doing a lot more work in Acrobat with JS over the next month so I will be posting more questions and will notify you if i do... and i hope it will be in your area of expertise... CJ
leakim971Multitechnician
Top Expert 2014

Commented:
you're welcome, have a nice week-end

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial