Skip to content

Instantly share code, notes, and snippets.

@JulioV
Created May 28, 2020 13:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JulioV/8f3bfd3113764fc9c66726a12d651820 to your computer and use it in GitHub Desktop.
Save JulioV/8f3bfd3113764fc9c66726a12d651820 to your computer and use it in GitHub Desktop.
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