Skip to content

Instantly share code, notes, and snippets.

@FelipeBudinich
Last active August 29, 2015 14:02
Show Gist options
  • Save FelipeBudinich/3fc637a253a701941b61 to your computer and use it in GitHub Desktop.
Save FelipeBudinich/3fc637a253a701941b61 to your computer and use it in GitHub Desktop.
Javascript, Client side domain validation.
<!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