$(document).ready(function(){ $("#psswd").keyup(function(e){ if (e.keyCode == 13) $("#submit_button").click(); }); $("#uid").keyup(function(e){ if (e.keyCode == 13) $("#submit_button").click(); }); $("#uid").focus() $("#submit_button").click(function(){ var un = $("#uid").val() var pass = $("#psswd").val() if ((un == "")) { $.prompt("Please enter a Username!", { buttons: {"Ok" : true }, opacity: 0.2 }); return; } if (pass.length == 0) { $.prompt("Please enter a Password!", { buttons: {"Ok" : true }, opacity: 0.2 }); return; } startButtonAnimation("submit", "Logging in..."); $.post( "/post/auth", {"func" : "authenticate" , "username" : Trim(un), "password" : pass}, function(data){ if (data == 2) { $.prompt("User account is locked. Please restart server.", { buttons: {"Ok" : true }, opacity: 0.2 }); stopButtonAnimation("submit", "Failed!"); return; } if (data == 1) { $.prompt("Invalid Username/Password. Please try again.", { buttons: {"Ok" : true }, opacity: 0.2 }); stopButtonAnimation("submit", "Failed!"); return; } else { window.location = data stopButtonAnimation("submit", "Success!"); } } ); }); });