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

avatar
Administrator
Administrator


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





© PunBB Design


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



Forum Administrator, Coolyou,
Due to the volume of PMs I receive, I do not provide support via PM.
We have community forums for most support requests. If it's truly confidential, please do PM me.

Useful links:
-> Before asking question,  please use a Search option.
-> If you want to check our staff members click here.
->  Forum rules, this is a MUST READ thread.
->  FAQ (Frenquently asked questions)

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

2
Offline

  Sharon

avatar
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

avatar
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

avatar
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

avatar
Punbb Rookie
Punbb Rookie
very good tuto thx

Powered by PunBB
Currently 0 users have thanked Andrei34 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