We help IT Professionals succeed at work.

Acrobat JavaScript to check for matching email addresses

299 Views
Last Modified: 2010-04-16
Experts,

I have a PDF form with two fields so users can enter their email address twice before submitting the form.  I need an Acrobat JavaScript that can verify if the two text fields match.  If they match, it should submit the data, if they do not match, a message should be shown to let the user know that the email address entered do not match.  

The two fields are named ConfEmail & ConfEmail2.  This is what I have so far, but when I press the button nothing happens:

if(this.getField("ConfEmail")==this.getField("ConfEmail2"))
FRsubmit(); \\ This is a fuction that highlights any missing required field.  
else
console.println( "The e-mail addresses entered do not match" );

I really need this ASAP.  Thanks.
Comment
Watch Question

ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
Check:

if(this.getField("ConfEmail").value==this.getField("ConfEmail2").value)


ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
Be also aware that both values are equal when both are empty.

ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:
Check this:

if(getField("ConfEmail").value>"" && getField("ConfEmail").value==getField("ConfEmail2").value){
  FRsubmit();  
} else {
  console.println( "The e-mail addresses entered do not match" );
}




Author

Commented:
I'm not sure if I'm doing something wrong.  

I double clicked my submit button and went to the actions tab.  There I chose to add an action (Run a JavaScript) with Mouse Up as the Trigger.  Then on the JavaScript Editor I added:

if(getField("ConfEmail").value>"" && getField("ConfEmail").value==getField("ConfEmail2").value){
  FRsubmit();  
} else {
  console.println( "The e-mail addresses entered do not match" );
}

And nothing happens when I click the submit button.  I'm using Acrobat 7 Pro.

Author

Commented:
I was missing some information.  Currently, if I enter an email address correctly on both text fields, it works fine, but if the addresses do not match, I don't get any message.  So, for some reason the   console.println( "The e-mail addresses entered do not match" ); is not working.
Systems architect
CERTIFIED EXPERT
Top Expert 2006
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
ZvonkoSystems architect
CERTIFIED EXPERT
Top Expert 2006

Commented:

Author

Commented:
Awesome.  You get 500 points well deserved. Thanks.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.