In a JSP I have two fields. When the page is loaded, the focus is set to the first field. When I input the value from a barcode reader, it “presses” the enter key so the form is submitted.
I need to use the barcode reader to input the first value in the first field, then focus the second field so I can scan the second value and only then submit the form.
The javascript function I’m trying to use is this:
$().ready(function() {
$("#serialNumber").val("").focus();
$("#serialNumber").keypress(function(e) {
if (e.which == 13) {
$("#serialClient").val("").focus();
} else {
$("#button").submit;
});
}
});
The form submit button is:
<button type="submit" class="submit">Submit</button>
But if I change this button type to “button” I can submit the form any longer.
How can this be fixed?
Thanks in advance,
You need watch for the click on the button to then submit the form. You can check out the jsFiddle or the quick example below.