passcode to show content
I'm trying to create a simple set-up so that when a certain code is entered into a form box, then a hidden element shows. If you could help me out, that'd be great. Thanks!
<form>
Enter the passcode to see the content:
<input id="pwd" type="text" name="pwd" />
</form>
<div id="content" style="display:none;">
testing 123
</div>
<script>
开发者_开发百科 $function(){
$(form).keyup(function() {
$('input').trigger('change');
});
if ($('pwd').val() == supportingcauses){
$('content').show('slow');
}
};
</script>
http://jsfiddle.net/jaruesink/RTG4f/
It seems your only problem in your code is that your codes missing a bit of chars. Here's how it should look:
...
if ($('#pwd').val() == "supportingcauses"){
$('#content').show('slow');
}
...
I added the #
to signify its an id and the parenthesis to signify supportingcauses
is a string.
EDIT
The full correct code would be:
<form>
Enter the passcode to see the content:
<input id="pwd" type="text" name="pwd" />
</form>
<div id="content" style="display:none;">
testing 123
</div>
<script>
$("#pwd").keyup(function() {
if ($('#pwd').val() == "supportingcauses"){
$('#content').show('slow');
}
});
</script>
Or as shown here: http://jsfiddle.net/nayish/MrjxY/3/
This is not a secure method of password safety but here is how to do it,
http://jsfiddle.net/RTG4f/1/
精彩评论