I\'m using the django-simple-captcha app for my django based website, I am able to integrate the captcha form field into my form, but the problem is, how do I create a butto
Here's a working implementation in javascript:
$(function() {
// Add refresh button after field (this can be done in the template as well)
$('img.captcha').after(
$('Refresh')
);
// Click-handler for the refresh-link
$('.captcha-refresh').click(function(){
var $form = $(this).parents('form');
var url = location.protocol + "//" + window.location.hostname + ":"
+ location.port + "/captcha/refresh/";
// Make the AJAX-call
$.getJSON(url, {}, function(json) {
$form.find('input[name="captcha_0"]').val(json.key);
$form.find('img.captcha').attr('src', json.image_url);
});
return false;
});
});
Then you just need to add some CSS for the class captcha-refresh
, perhaps place an image in the and you're good to go!