Adobe Acrobat JavaScript Validation Test for 3 PDF Fields

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);  
        {
                                                                                                                              }
EnflowAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

leakim971PluritechnicianCommented:
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

EnflowAuthor 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 ?
leakim971PluritechnicianCommented:
remove line 3 and the code on AG, do the readonly stuff work fine ?
Price Your IT Services for Profit

Managed service contracts are great - when they're making you money. Yes, you’re getting paid monthly, but is it actually profitable? Learn to calculate your hourly overhead burden so you can master your IT services pricing strategy.

EnflowAuthor 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
EnflowAuthor 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 ??
leakim971PluritechnicianCommented:
I'm at home and don't have Acrobat here, I will check tomorrow morning
leakim971PluritechnicianCommented:
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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
EnflowAuthor 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
leakim971PluritechnicianCommented:
you're welcome, have a nice week-end
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Acrobat

From novice to tech pro — start learning today.