Last active
August 29, 2015 14:02
-
-
Save FelipeBudinich/3fc637a253a701941b61 to your computer and use it in GitHub Desktop.
Javascript, Client side domain validation.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Javascript, Client side domain validation.</title> | |
<script type="text/javascript"> | |
function checkAllowedDomains() { | |
// add allowed domains on the "allowed" array | |
var allowed = ['127.0.0.1'], | |
isAllowed = false; | |
for (i = 0; i < allowed.length; i++) { | |
if (window.location.hostname === allowed[i]) { | |
isAllowed = true; | |
} | |
} | |
return isAllowed; | |
} | |
console.log(checkAllowedDomains()); | |
</script> | |
</head> | |
<body> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment