Created
May 28, 2020 13:30
-
-
Save JulioV/8f3bfd3113764fc9c66726a12d651820 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
var onloadCallbackCaptcha = function(sitekey) { | |
grecaptcha.render('div-recaptcha'); | |
}; | |
function showComments() { | |
// Remove button | |
var staticmanButton = document.getElementById('staticman-button'); | |
staticmanButton.parentNode.removeChild(staticmanButton); | |
// Un-hide comments | |
var staticmanComments = document.getElementById('staticman-comments'); | |
staticmanComments.style.display = 'block'; | |
// load recaptcha script (delete if not using recaptcha) | |
var script = document.createElement('script'); | |
script.setAttribute('src', 'https://www.google.com/recaptcha/api.js?onload=onloadCallbackCaptcha&render=explicit'); | |
document.head.appendChild(script); | |
} | |
function checkForm(form){ | |
if(typeof(grecaptcha) === "undefined"){ | |
form.warningComment.style.display = 'block'; | |
form.warningComment.innerText = "There was a problem loading the reCaptcha so it is not possible to submit a comment at the moment"; | |
return false; | |
} | |
else if(grecaptcha.getResponse() == ""){ | |
form.warningComment.style.display = 'block'; | |
form.warningComment.innerText = "Please confirm you are not a robot :)"; | |
return false; | |
} | |
else if(form.yourname.value == ""){ | |
form.warningComment.style.display = 'block'; | |
form.warningComment.innerText = "Please type your name"; | |
return false; | |
} | |
else if(form.yourcomment.value == ""){ | |
form.warningComment.style.display = 'block'; | |
form.warningComment.innerText = "Please type a comment"; | |
return false; | |
} | |
else{ | |
form.submitButton.disabled = true; | |
form.warningComment.style.display = 'none'; | |
form.warningComment.innerText = ""; | |
form.submitButton.innerText = "Sending..."; | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment