Sign in

Documentation: Hide an e-mail address from a spam bot

#2468
champi

One question however: I know that the code you gave is just an example but I think you have to leave out the code value=Y because otherwise the value Y is always send to the server. Instead, I think, you have to check if the value is not null?

Indeed you’re right. I did a little mistake. You can just check if the inout is or is not checked. You ca use a simple input too. just check the length of the value and if it’s not equal to zero, then prevent the form send.

Now the correct code :

$("form input[type='submit']").click(function (e) {
    var form = $(this).closest('form');
if ($("input[name='login']",form).is(':checked')) { // If honeypot is lit
        e.preventDefault(); // We don't send the form
        // Do something that looks as if the form was sent...
    } 
});