function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Sriram MSriram M 

Adding a Custom captcha to Visual Force page

Hi all,

I have a requirement for adding a Captcha mechanism to a form. 
I don't want to use the Google reCaptcha. So I did some searching and found the below link.

http://www.tehnrd.com/simple-visualforce-captcha/

I was able to add the captcha as given in the above link and make it functional. 

Now the problem starts when I try to add the logic for refreshing the captcha (for loading a different captcha pattern). 
I tried adding a commandlink. It is refreshing the entire page along with the captcha. I wanted to have an AJAX like functionality which refreshes the particular captcha section alone.

The APEX code which generates the captcha resides in my controller class file which is responsible for controlling the entire form.

How can I make the refresh without affecting the rest of the form functionality? I have to invoke the specific method which generates the captcha, get the updated captcha value and render it in the captcha section.

Please help me out with your suggestions and solutions.

Thanks in advance.

Deepak Kumar ShyoranDeepak Kumar Shyoran
You can implement Captcha on visualforce by integrating Salesforce with captcha.
Here is a link of Salesforce document where they clearly mentioned how to implement Captcha on VF pages
https://developer.salesforce.com/page/Adding_CAPTCHA_to_Force.com_Sites
Sriram MSriram M
Thanks for the quick response Deepak. 

The link which you provided suggests on how to use the Google reCaptcha.
But I didn't wanted to use the Google reCaptcha. 

I wanted to have a captcha which is completely based on Apex (or Salesforce).

Thanks

Sriram MSriram M
I figured it out guys.

It was a simple attribute. "reRender".
I have added the reRender attribute for re-rendering the form on clicking the commandLink and it worked.
Re-render renders the content of an element without reloading the page. And fortunately it keeps the typed information intact in the form.

Thanks 
Deepak Kumar ShyoranDeepak Kumar Shyoran
Please close your question by selecting a best answer for your question so that it'll able for others as a solution to the same problem.
ameghnathi1.3923679616717695E12ameghnathi1.3923679616717695E12
Sriram, link you mentioned above is broken. I am not able to access it. Can you share your code? we have exact same requirement.
Aishwarya SubramanianAishwarya Subramanian
We also have a requirement where we need to use Captcha which is not provided by google. Can share thought about how we could implement this