CF 8 Image CAPTCHA » toScript JS Validation
I finally got to the point where I had seen just about as much spam that I could handle and being somewhat of a ColdFusion developer, I decided to take some action ...
My first shot at stopping the pesky spammers was by implementing a Lyla CAPTCHA. However, I had some problems getting the CFC working correctly, and after several failed attempts, I tried to use Rob Gonda's AjaxCFC with Lyla too ... Yet, I still wasn't able to get the CAPTCHA working ...
So, after talking with a friend, that is quite familiar with ColdFusion ... he asked me why I didn't just use CF8's native support for CAPTCHA's with the CF Image tag ...
I really hadn't even thought of it ... I found the answer ...
I learned quite a bit more CF code in order to get the image going along with some JS validation ... For starters, I got the base idea from Camden's example of using CF CAPTCHA ... but I didn't want to break the layout of my form page by expanding the form during validation error messages ... I had to find a way to convert Ray's form validation in to JavaScript validation ...
Well, I searched through hundreds of pages in order to find a solution to my problem ... How to turn ColdFusion variables ... in to JavaScript variables ... I didn't have a clue ... until I found another non-related tutorial example by ... (guess who ...) yep, it's Ray again ... that alluded to the toScript method ... almost everywhere else I had searched, returned answers which expresses that there was no way in converting a ColdFusion object in to a JavaScript object ...
So, I was one step closer to my goal ... then, I hit another obstacle ... the error strings all ended with a "<br />" in order to separate the error strings when returned to the page ... that would not convert in to a JavaScript variable ... New Problem ... how could I insert a line break » Carriage Return in to a ColdFusion variable ... and return it in JavaScript without throwing errors?
Thanks to the friendly Ben Nadel ... for his contributions to the CF community again ... where I found a post of his on converting CF characters to JS ...
So, with a bit of my own efforts some where in there ... I finally have a CF CAPTCHA on my site ... and can say good bye to the spammers ... bye spammers ...
















There are no comments for this entry.
[Add Comment]