JS validating barcode scanner data too early
<p>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.</p>

<p>Here is what I have so far:</p>

<pre><code>&lt;form name="getBarcode" method="GET"&gt;
Barcode: &lt;input id = "barcodeEntry" type="text" name="barcode" onkeyup = "checkBarCode()" /&gt;&lt;br /&gt;
&lt;/form&gt;
</code></pre>

<p>and the JS</p>

<pre><code>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;
    }
}
</code></pre>

<p>Thanks in advance for any possible help!</p>
