1

I have a WordPress site with a form that I need to add a captcha to. The form isn't it's own template or even on it's own page but it is a single php file that is included on all of the pages. The actual form is in the shape of a drop down menu. When a user clicks on the "request info" link, the form drops down from the navbar. Do to the way it is set up I can't use a WordPress plugin.

Normally, I could I just add a php captcha script and be done with it but the form action is set to post to an external website. When the visitor submits the form, it goes to another website that collects the info, as you can see here:

<form action="https://www.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST" name="contact" id="contact" onsubmit="return checkform(this);">

Because the form isn't verified with a php file on the sites server, I don't know how to verify the captcha and get it to work. Does anyone have any suggestions?

user715564
  • 1,650
  • 2
  • 25
  • 60

1 Answers1

1

The only way to do it would be to make an ajax call on submit to your server where you check the captcha code. If the code is valid, then submit the form. If it isn't display the error and don't allow the form to submit.

If you are using Recaptcha, check this SO: using reCAPTCHA with ajax....javascript loading problem

If a general Captcha is what you are doing: jQuery ajax validate captcha

The answers are more focused that what you are looking for, but will at least get you pointed in the right direction.

Community
  • 1
  • 1
Tim Withers
  • 12,072
  • 5
  • 43
  • 67
  • That's a spectacular answer. Thank you very much. I will look at the links right quick and see what I can find out. – user715564 Jun 07 '12 at 21:21
  • The jQuery dataType should be 'text', since you are not returning XML. `data: captchaValue,` should be `data:$("#recaptcha_response_field").val(),` – Tim Withers Jun 07 '12 at 21:59