Skip to content

Instantly share code, notes, and snippets.

@colecmc
colecmc / no-captcha-recaptcha-validation.js
Created April 25, 2015 18:08
How to make Google reCAPTCHA a required field? - What you have to do is prevent the form submission until you can validate the user response by using the Google reCaptcha verify callback, then, if it passes, allow the form to submit. Check the documentation: https://developers.google.com/recaptcha/docs/display#example
var RC2KEY = 'sitekey',
doSubmit = false;
function reCaptchaVerify(response) {
if (response === document.querySelector('.g-recaptcha-response').value) {
doSubmit = true;
}
}
function reCaptchaExpired () {
@colecmc
colecmc / getNextHighestZindex.js
Last active June 1, 2016 21:29
Gets highest z-index and adds 10 or adds number specified in parameter. Use this method sparingly as it can be a slow operation, potentially locking up the UI.
/**
* @version 1.0.0
* @author (@colecmc)
* @param {number} incrementBy
* @returns {number}
* Gets highest z-index and adds 10 or adds number specified in parameter.
* Use this method sparingly as it can be a slow operation, potentially locking up the UI.
* Map over ALL elements to find the z-indexes.
* Filter out the elements where z-index is 'auto'.
* Reduce remaining elements down to the highest value, then add 10.