The problem is , when i hit enter key , it refreshes the page and put me into the same page , it doesnt even execute the alerts
I am using this javascript code to login by hitting enter key but it doesn't work .
$("#btnLogin").keypress(function (e) {
var code = e.which;
alert("stage 1");
if (code == 13) {
e.preventDefault();
alert("stage 2");
}
});
i have used keyup,keydown also but they give me the same result, this is my html button
<button class="btn btn-success" type="button" id="btnLogin">
Sign In</button>
Any help appreciated .