Skip to content

Instantly share code, notes, and snippets.

@adammcarth
Created October 8, 2014 09:41
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 adammcarth/8d3e89dde8c1a466b829 to your computer and use it in GitHub Desktop.
Save adammcarth/8d3e89dde8c1a466b829 to your computer and use it in GitHub Desktop.
// Validate using a custom URL (external server script)
function validates_instance_url( url, attr ) {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if ( xhr.readyState === 4 ) {
if ( xhr.status !== 200 || xhr.responseText === "false" || xhr.responseText === "0" ) {
return false;
} else {
return true;
}
}
}
xhr.open( "GET", url + "?value=" + encodeURIComponent(attr), true );
xhr.setRequestHeader( "Instance-Validation", attr );
xhr.send();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment