on change event using jQuery

First of all I apologize, I am posting tons of questions will silly problems. This is very much the first time I am going to use JQuery heavily. So now my problem is, I have a text field, which gets input from a usb device (works as a keyboard wedge), as soon as this INPUT field is populated I want …

via Css Website development » Search Results » ajax:

on change event using jQuery

First of all I apologize, I am posting tons of questions will silly problems. This is very much the first time I am going to use JQuery heavily. So now my problem is, I have a text field, which gets input from a usb device (works as a keyboard wedge), as soon as this INPUT field is populated I want to make an AJAX call, sending the read value to server. I thought on using change event using the attached code, but it isnt working correctly reason being, because the input is 15 digit alpha numeric and populates one by one, just after the first character comes in, the change event triggers. What I want is, make the ajax call after the complete input is in the textfield, make the ajax call and then clear the text field for next input.
$(document).keydown(function()
$(“#serialCode”).focus();
$(“#serialCode”).change(function()
var $serialNumber = $(“#serialCode”).val().substring(0,9) ;
alert($serialNumber);
$(this).val(“”);
);
});
……………………………………..

I’d have a the keydown event on the text field first. within that event i’d be checking for the length of the field and when it reached 15 then do the post back
$(“#serialCode”).change(function()
var $serialNumber = $(“#serialCode”).val().substring(0,9) ;
//check the length here first
var codeLen = $(‘.hiddenCodeLength’).val();
if ($serialNumber.length == codeLen)

alert($serialNumber);
$(this).val(“”);

});

For more info: on change event using jQuery

Css Website development » Search Results » ajax

on change event using jQuery

Share this post:

Related Posts

Leave a Comment