2015-05-07, 16:11
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
Anti-Spam question on registration
1º - 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");
}
});
}
};
2º - Preview
© PunBB Design
If you have any questions related to this topic create a topic with the following title: Anti-Spam question on registration |