I have a basic login form that uses ajax to login. If the details are incorrect, a text is displayed on which the login error has failed. When this is shown by the last text box, the user enters the text, losing focus.
Is it possible to set focus on the last text field that was included by the user before clicking the "Send / Press" button?
$('#login').click(function (e) { e.preventDefault(); $.ajax({ type: "POST", dataType: "text", url: "login.php", data: "username=" + $("#username").val() + "&password=" + $("#password").val(), cache: false, success: function(reply) { if (reply.indexOf("Success") >= 0) { location.reload(); } else { $("#loginResult").html("Login Failed");
Any suggestions, thanks.
jquery setfocus
Elliott
source share