Created
July 10, 2014 16:07
-
-
Save willwright82/4c7f08571b1b6708f051 to your computer and use it in GitHub Desktop.
Are you human? Math captcha
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Are You Human?</title> | |
<script type="text/javascript"> | |
var a = Math.ceil(Math.random() * 10); | |
var b = Math.ceil(Math.random() * 10); | |
var c = a + b | |
function DrawBotBoot() { | |
document.write("What is " + a + " + " + b + "? "); | |
document.write("<input id='BotBootInput' type='text' maxlength='2' size='2'/>"); | |
} | |
function ValidBotBoot() { | |
var d = document.getElementById('BotBootInput').value; | |
if (d == c) { | |
$('#submit').removeAttr("disabled"); | |
$(".answer").detach(); | |
$('#captchaform').append('<p class="answer">Correct!</p>'); | |
return true; | |
} else { | |
$(".answer").detach(); | |
$('#captchaform').append('<p class="answer">Wrong! Are you human?</p>'); | |
return false; | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<div id="captchaform" class="form-group col-lg-12"> | |
Are you human? | |
<br /> | |
<script type="text/javascript"> | |
DrawBotBoot() | |
</script> | |
<input id="captcha" type="hidden" name="contact_captcha" value="ValidBotBoot();"> | |
<input id="Button1" type="button" value="Check answer" onclick="ValidBotBoot();" /> | |
</div> | |
<div class="form-group col-lg-12"> | |
<input type="hidden" name="save" value="contact"> | |
<button id="submit" type="submit" class="btn btn-primary" disabled="disabled">Submit</button> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment