• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 201
  • Last Modified:

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.  
1 Solution

Does your barcode scanner have a start/end character sequence?
Scott Fell, EE MVEDeveloperCommented:
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;


<form id="form1" name="form1" method="post" action="">
  <input type="text" name="textfield" id="textfield"  class="barcode"  />
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
try the onkeyup javascript event on the field:

<input type="text" name="fld" onkeyup='this.value = ' ';" />
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

htmlmaleAuthor Commented:
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.
htmlmaleAuthor Commented:
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.
htmlmaleAuthor Commented:
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.
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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.
htmlmaleAuthor Commented:
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.
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
i think you're right, the only way to do it would be to keep track of the time spent in the field
Question PAQ'd and stored in the solution database.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now