Created
October 8, 2014 09:41
-
-
Save adammcarth/8d3e89dde8c1a466b829 to your computer and use it in GitHub Desktop.
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
// 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