I'm writing a web-program that takes input on a form from a barcode scanner. The barcode scanner converts the barcode to text and then uses keystrokes to type the text very quickly (< 1s) into input box. There is a chance that someone may key in a barcode by hand as well.
here's what i need:
1. verify form is at least 9 characters (some of my barcodes will be longer), if it is then:
2. wait 2 seconds and submit form
3. but if another keystroke occurs, clear the timer and wait 2 seconds from then (in case someone is typing by hand and isn't finished yet).
I have very basic JS experience and tried to splice two scripts together but I couldn't get it working, here is what I have (dont laugh!):
if ( field.value.length >= 9 )
AND THE FORM
<form method="post" action="submit.php">
<input name="barcode" type="text" onkeyup="check(this);">
<input type="submit" value="go!">
please help me and if you can remove any unnecessary returns in my script, I need it to be as compact as possible (if you don't mind)
Thanks in adv.,