I have a basic login form, which uses ajax to login users. If the details are incorrect text is displayed showing login has failed. When this is shown the last textbox the u
Subscribe all of your inputs to the focusout event
$('.input').focusout(function () { $('#myform').data('lastSelected', $(this)); });