Hello all,
I am using a barcode scanner to enter in data and then send the code back to the server to validate it against the database. I'm having a problem of the javascript kicking in after the first character is entered. I need to find a way to delay this so the full 19 charaters can be entered. The barcode I am trying to check contains numbers, spaces, and dashes.
Here is what I have so far:
<form name="getBarcode" method="GET">
Barcode: <input id = "barcodeEntry" type="text" name="barcode" onkeyup = "checkBarCode()" /><br />
</form>
and the JS
var checkBarCode = function() {
var barcode = $("#barcodeEntry").val();
if (barcode.length == 19) {
var url = "check/";
var data = {barcode:barcode};
var args = {type:"GET", url:url, data:data, complete: checked};
$.ajax(args);
return false;
} else {
alert("something went wrong here");
return false;
}
}
var checked = function(res, status) {
if (status == "success") {
alert("Valid");
return false;
} else {
alert("Not Valid");
return false;
}
}
Thanks in advance for any possible help!