How to stop a form from submitting when running barcode scanner
Best solution I have found so far
$(":input").keypress(function(event){
if (event.which == '10' || event.which == '13') {
event.preventDefault();
}
});
I voted for existdissolve's answer because the scanner should be configurable.
However, a very simple javascript solution would be to return false onSubmit unless the submit button is actually clicked allowing the form to be submitted. Something like this --
<script language="javascript">var p = false;</script>
<form method="post" onsubmit = "return(p)">
<input type = "text" name = "text" />
<input type = "submit" value = "submit" name = "submit" onClick = "javascript: p=true;" />
</form>
Most scanners allow you to program what characters are sent as part of the scan. You can usually find the scanner's model manual online, download it, and then scan the correct programming codes to get the scan to send through what you want.