Forums

Alternative captcha

riga75 15 Jan, 2010
Instead of the classic captcha you can have a field with the question, what is 2 +2 and he has to put 4 indicate otherwise error?
Thanks

stefano
GreyHead 15 Jan, 2010
Hi stefano,

Yes you can. Here's one implementation in JavaScript. This generates two random numbers between 1 & 10 and disables the submit button until the sum is entered. (You could also do something similar using server-side validation.)
Form HTML
<div class="form_item">
    <div class="form_element cf_textbox">
        <label class="cf_label" style="width: 150px;">What is <span id='x1'> </span> + <span id='x2'> </span> ? (verification)</label>
        <input class="cf_inputbox required validate-number" maxlength="150"
            size="15" title="" id="veri" name="veri" type="text" />
        <a class="tooltiplink" onclick="return false;">
            <img height="16" border="0" width="16" class="tooltipimg" alt=""
                src="components/com_chronocontact/css/images/tooltip.png" />
        </a>
        <div class="tooltipdiv">What is X + Y ? (verification) :: This verification is to prevent abuse of this system.</div>
    </div>
    <div class="cfclear"> </div>
</div>

<div class="form_item">
    <div class="form_element cf_button">
        <input value="Submit" name="submit" id='submit' type="submit" />
    </div>
    <div class="cfclear"> </div>
</div>
Form JavaScript
window.addEvent('load', function () {
	// user verification 
	var x1 = Math.floor(Math.random()*10) + 1;
	//console.log(x1);
	var x2 = Math.floor(Math.random()*10) + 1;
	$('x1').innerHTML = x1;
	$('x2').innerHTML = x2;
	var veri = $('veri');
	$('submit').disabled = true;
	veri.addEvent('change', function() {
		if ( veri.value == x1+x2 ) {
			$('submit').disabled = false;
		} else {
			$('submit').disabled = true;
		}
	});
});

Bob
riga75 16 Jan, 2010
Sorry Bob, I took the demo form on your component and I added two pieces of code that you see me you posted, I did a test and I put a sum wrong but sends the same form ... if you do want access my joomla so you can control where I went wrong, thanks a lot

stefano
casper 22 Mar, 2010
How can I enter this code in my form?
I must change the html code of my exzisting form, or I can enter just the javascript code, because i have ready a form in my website and i want just to change the ReCaptcha for the standart look in the alternative mode like e.g 2+2=4?

Please help me, because I'm just a step before ChronoForms be my only and true love 😛 .

Again sorry for my poor english and a big thanks to GreyHead.

I will do my best to support this exellent work.
GreyHead 22 Mar, 2010
Hi casper,

The block marked Form HTML goes in the Form HTML box on the Form Code tab somewhere in the existing form html; the JavaScript Code block goes in the JavsScript Code box.

Bob
casper 22 Mar, 2010
and why is saying * the recapcha you have entered is not entered correctly??



please....
GreyHead 22 Mar, 2010
Hi casper,

Because you still have the ReCaptcha plugin enabled?

Bob
casper 23 Mar, 2010
Solved.

thnx for your support GreyHead.
jstratos 08 Mar, 2012
Thanks Greyhead!!! Looked all over for this.
StingerMKO 30 Jul, 2012
Hi,
I have a question regarding this thread.
When I enter the result in the field it is not verified when I just click on the submit button after typing. I have to click outside the input field and after this on the submit button. As I styled the submit button with an image, so you can not see, if it is enabled or disabled, it might be a bit confusing for the user to enter the correct result, click on submit and nothing happens.
Do you have any ideas to solve this?
Kind regards,
Malte
GreyHead 30 Jul, 2012
Hi StingerMKO,

You should probably use two images so that it is clear if the button is enabled or not.

You can also change this line:
veri.addEvent('change', function() {
to
veri.addEvent('keyup', function() {
which should fire the code after each keypress rather than 'onChange' which requires the extra click in IE.

Bob

PS This captcha code isn't very effective as it can be bypassed by turning JavaScript off. If you are using CFV4 then you can use the Security Question action to do this more effectively, Please see this FAQ
StingerMKO 30 Jul, 2012
This works!
Thanks a lot.
This topic is locked and no more replies can be posted.