Created
November 2, 2015 08:02
-
-
Save Archie22is/bb4bb0dc166040b87461 to your computer and use it in GitHub Desktop.
Simple jQquery require password to view resource / web page
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> | |
<meta charset="UTF-8"> | |
<title>jQuery Login Sample | https://github.com/Archie22is</title> | |
</head> | |
<body> | |
<input type="password" id="pass"> <input type="button" id="b" value="Login"><br> | |
<span id="err"></span> | |
</body> | |
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script> | |
jQuery( document ).ready(function($) { | |
$("#b").click(function() { | |
var password = "password"; | |
if($("#pass").val() !== password) { | |
$("#err").text("Incorrect password"); | |
} | |
else { | |
$("#err").text("Password correct! Do whatever you need to do here."); | |
} | |
}); | |
}); | |
</script> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment