Created
November 28, 2017 01:48
-
-
Save tjmaxwell/e2aa18c9e8c29afb66c13a34d5cb545a to your computer and use it in GitHub Desktop.
For customers that request Captcha. Google ReCaptcha won't work in Shopify for many reason as it has to be server-side submitted and we don't have access to Shopify hosting. So a simple solution is to use a Simple Captcha like this;
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
<!-- add this right after the textarea html code and before the submit / clear button --> | |
<!-- Captcha Placement --> | |
<div class="captcha"> | |
How much is: <input type="text" readonly="readonly" id="question"/> | |
Answer:* <input type="text" id="answer"/> | |
</div> | |
<!-- Captcha Placement --> |
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
{% if template contains 'contact' %} | |
{{ 'https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js' | script_tag }} | |
<script type="text/javascript"> | |
$(document).ready(function() { | |
var n1 = Math.round(Math.random() * 10 + 1); | |
var n2 = Math.round(Math.random() * 10 + 1); | |
$("#question").val(n1 + " + " + n2); | |
$(".contact-form").submit(function (e) { | |
if (eval($("#question").val()) != $("#answer").val()) { | |
$("#answer").css('box-shadow', '0px 0px 7px red'); | |
e.preventDefault(); | |
} | |
}); | |
}); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment