Good art is a taste, good design is an opinion.


Come as guest, stay as family.
Board Index

Come as guest, stay as family.


You are not connected. Please login or register

Foto

[Javascript] Anti-Spam question on registration



View previous topic View next topic Go down Message [Page 1 of 1]

1
Offline

  Shadow

Shadow
Administrator
Administrator

[Javascript] Anti-Spam question on registration Alerte10

Tutorial: Anti-Spam question on registration

Allows you to add a custom question on registration steps to prevent spam bots.

Created by @Daemon


--> Tutorials, tips and tricks <--
Anti-Spam question on registration



- Javascript
Placement In all pages
Code:
[panda=js]window.onload = function() {
 if(window.location.href.search('agreed=true') >= 0) {
    //*Question*//
    var jQuestion = 'How much is 10 + 10?';
 
    //*Question answer*//
    var jAnswer = 20;
    var jMulti = document.getElementsByClassName("multi")[0];
    jMulti.innerHTML += '<dl>' +
                        '    <dt>' +
                        '        <label>Answer the question: *</label>' +
                        '    </dt>' +
                        '    <dd>' +
                        '        <input class="ltr" type="text" id="answer" size="25" maxlength="25">' +
                        '        <span style="font-size: 10px;color: gray;">' + jQuestion + '</span>' +
                        '    </dd>' +
                        '</dl>';
    document.querySelector("input[name="submit"]").addEventListener("click", function(d){
    if(document.getElementById("answer").value != jAnswer) {
        d.preventDefault();
        alert("The answer is incorrect");
    }
    });
 }
};


- Preview
[Javascript] Anti-Spam question on registration ME7gc3I




© PunBB Design


[Javascript] Anti-Spam question on registration Act_bottom If you have any questions related to this topic create a topic with the following title:
Anti-Spam question on registration

Powered by PunBB
Currently 0 users have thanked Shadow for this post:

2
Offline

  Sharon

Sharon
Punbb Rookie
Punbb Rookie
This is a great javascript code. I think it's important to have something like this installed to prevent spambots from attacking your forum. My only frustration is when people ask such specific questions that not everyone might know like "Who is the President of India" or generic question like "Name a state that starts with M" and you have to type in the exact state when there are several states that start with the letter M. 2+2 is simply and has one answer so I like that. Smile

Powered by PunBB
Currently 0 users have thanked Sharon for this post:

3
Offline

  Bossanova

Bossanova
Punbb Rookie
Punbb Rookie
This is prettty helpful to have. Smile I'm fortunate that my forum provider already has some questions you can add or remove.

Powered by PunBB
Currently 0 users have thanked Bossanova for this post:

4
Offline

  htb24

htb24
Newbie
Newbie
Thanks for sharing this! This is a great tool to use to prevent spam on your forum. It is good that you can customise the question too to increase the difficulty.

Powered by PunBB
Currently 0 users have thanked htb24 for this post:

5
Offline

  Andrei34

Andrei34
Punbb Rookie
Punbb Rookie
very good tuto thx

Powered by PunBB
Currently 0 users have thanked Andrei34 for this post:

6
Offline

  Sponsored content



Powered by PunBB
Currently 0 users have thanked Sponsored content for this post:

View previous topic View next topic Back to top Message [Page 1 of 1]


Topic URL's

URL
BBcode
HTML

Permissions in this forum:
You cannot reply to topics in this forum