I have a form where users scan in a barcode, the barcode reader automatically enters a carriage return in the value causing the form to submit since the browser chooses the first button as the default. How can I disable anything from happening when the enter key is pressed when entring a value in that textbox?
Share
You’ll need to do it with javascript. In your markup for the text box, add an onkeydown handler like so:
This will return false if the key was the enter key, which will cancel the form submission.