htmlmale
asked on
Asp webpages...Only allow scanning into text boxes...no typing
I have a web based application in asp that utilizes forms.
I would like to ONLY allow a barcode scanner to input data into the text fields, not allow typing.
Any suggestions?
My only current thought is to set a timer on the field and only allow .5 seconds before submitting the form once a character has been entered into the text box.
I would like to ONLY allow a barcode scanner to input data into the text fields, not allow typing.
Any suggestions?
My only current thought is to set a timer on the field and only allow .5 seconds before submitting the form once a character has been entered into the text box.
Maybe over simple but you could make the text field 1px. And if you wanted to to get fancy make an ajax tag next to it that looks up the code and fills in the items name.
<style type="text/css">
<!--
input.barcode {
width: 1px;
}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" id="textfield" class="barcode" />
</form>
</body>
<style type="text/css">
<!--
input.barcode {
width: 1px;
}
-->
</style>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<input type="text" name="textfield" id="textfield" class="barcode" />
</form>
</body>
try the onkeyup javascript event on the field:
<input type="text" name="fld" onkeyup='this.value = ' ';" />
<input type="text" name="fld" onkeyup='this.value = ' ';" />
ASKER
I've thought about making the text boxes invisible, but realistically don't think that would work very well. It would make it confusing to the users, and very difficult to troubleshoot the page.
ASKER
Regarding the barcode start/end character sequence question. We do require that the scanner submits a TAB suffix to move the cursor to the next field, however, we cannot require any unique prefix/suffixes as multiple customers will be using this page, and many of those customers will be using their scanners for applications other than mine.
ASKER
Regarding the onkeyup solution...I was REALLY hoping that his would work, however, the scanner works just like a keyboard entry, so the form submitted after the very first character was scanned. My barcode was "EZ1234", however, as soon as the E hit the text box, the form was submitted.
is there anything else the scanner submits to each field as it enters it that can distinguish it? if so, you can create a JS function that checks for that char, and then allow it to proceed based upon that char.
ASKER
Big Daddy...Unfortunately not. As far as I can tell, there's no real way to distinguish between someone typing into a text field and someone scanning into a text field. That's why I was thinking about a timed text field, where the instant someone enters a keystroke, they have .5 seconds to complete their entry before the form submits. That way, the scanner would complete, but a human typing would not. I would also have to disable the cut and paste ability on the page for this to work.
i think you're right, the only way to do it would be to keep track of the time spent in the field
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Does your barcode scanner have a start/end character sequence?