I am working with js and jquery. I have a test login page I'm working on and seem to be having trouble with the bind on the login button. In Chrome i see that the js file is loading, but when you click on the button it just refreshes the page. It doesn't show the alert section or shake if you enter the incorrect info, and it doesn't redirect to the main page if you enter the correct info. Here is my code:
HTML:
<body>
<div id="content">
<section class="ui-widget ui-corner-all">
<header class="ui-widget-header ui-corner-top">
Test Login
</header>
<div class="ui-widget-content ui-corner-bottom">
<p class="ui-state-error">Uername / Password Incorrect.</p>
<form>
<div>
<label for="username">Username:</label>
<input id="username" type="text">
</div>
<div>
<label for="password">Password:</label>
<input id="password" type="password">
</div>
<div>
<input id="btnLogin" type="submit" value="Login">
</div>
</form>
</div>
</section>
</div>
<div class="ui-widget-overlay" style"z-index: 1002;"> </div>
</body>
JS:
$(".ui-state-error").hide();
$("#btnLogin").button()
.bind ("click", function() {
if($("#username").val() != "test" && $("#password").val() != "test") {
$(".ui-state-error").show();
$("#login section").effect("shake", 150);
}
else {
document.location = 'index.html';
}
return false;
});
.button()from javascript block