I thought to share with others.
I have divided the entire code into three parts.
- captcha.cfm - Page where we will display the captcha image.
- Util.cfc - It contains a user defined function "generateRandomText" to generate random captcha text.
- refreshCaptcha.cfm - Page which will handle AJAX call while refreshing captcha image.
Lets see the "captcha.cfm" below:
Here, in above code I have used "ImageCreateCaptcha" function, which is added in ColdFusion 10 for captcha generation.
Lets see the "Util.cfc"
In this file, I have written a function called "generateRandomText" for generating captcha string. Logic is very simple, you can modify it according to your requirement.
Next, come to "refreshCaptcha.cfm":
We are making AJAX call to this file which again generates random captcha image and sends to browser for display.
So, this is whole story for generating and refreshing captcha image in ColdFusion!!!
Lets see the "Util.cfc"
In this file, I have written a function called "generateRandomText" for generating captcha string. Logic is very simple, you can modify it according to your requirement.
Next, come to "refreshCaptcha.cfm":
We are making AJAX call to this file which again generates random captcha image and sends to browser for display.
So, this is whole story for generating and refreshing captcha image in ColdFusion!!!