Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery blur alternative [duplicate]

Possible Duplicate:
Detect all changes to a <input type=“text”> (immediately) using JQuery

I have a textbox which a user enters data and on the onBlur event it does an AJAX request to validate the data they have entered. If it validates then a button becomes enabled. However users are getting confused that they have to tab out or click somewhere on the page for the button to become enabled.

Is there an alternative event or approach to the code I am using?

$('.serial').live('blur', function () {

  //Do AJAX to validate

  //If ok enable button
  $('#button').attr("disabled", "");

});
like image 473
Jon Avatar asked Aug 24 '26 13:08

Jon


2 Answers

You could use keyup, maybe adding a setTimeout for delaying the requests.

like image 198
nico Avatar answered Aug 27 '26 03:08

nico


Try keyup - it's fired after each key is pressed.

$('.serial').live('keyup', function () {
    //Do AJAX to validate

    //If ok enable button
    $('#button').attr("disabled", "");
});
like image 38
Rory McCrossan Avatar answered Aug 27 '26 05:08

Rory McCrossan