RandyRiegel
Programmer
I am making a webpage for a user to scan a barcode into an input box (keyboard wedge reader). As soon as I get a good formatted job number I want to set focus to a hidden field which will start processing of data. But I can not get the regular expression to match, have tried all kinds of example online.
The format of our job numbers are 123456-1-1. First section is always 6 digits, the second section is ALWAYS 1 and the last section is 1-12 (for month) without leading zero. I got my regular expression to work in a windows application (vb.net) to test it. Here is my javascript/jquery code.
NOTE: str variable is getting a value, in the commented line above whatever I typed into the txtBarcode would get copied to the Hidden1 field (which I unhid for testing).
Thanks,
Randy
The format of our job numbers are 123456-1-1. First section is always 6 digits, the second section is ALWAYS 1 and the last section is 1-12 (for month) without leading zero. I got my regular expression to work in a windows application (vb.net) to test it. Here is my javascript/jquery code.
JavaScript:
$(document).keyup(function () {
var str = $("#<%= txtBarcode.ClientId %>").val();
// $("#Hidden1").val(str);
var re = /^\d{6}\-[1]\-[1-9][0-2]?$/.match(str);
if (re == true) {
$("#Hidden1").focus();
}
});
NOTE: str variable is getting a value, in the commented line above whatever I typed into the txtBarcode would get copied to the Hidden1 field (which I unhid for testing).
Thanks,
Randy