/ Published in: jQuery
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
function random_between(to, from) {
return Math.floor(Math.random() * (to - from + 1) + from);
}
$(document).ready(function() {
var num1 = random_between(0,5)
var num2 = random_between(5,10);
$('label[for="captcha"]').text("What is "+num1+" + "+num2);
$('form').submit(function() {
if($('#captcha').val() == (num1+num2)) {
$('form').submit();
}
else {
alert("Your CAPTCHA IS NOT valid!");
return false;
}
});
});
Comments
 Subscribe to comments
                    Subscribe to comments
                
                