I need to scan a barcode with ASCII 29 (group separator) into an HTML input field, and replace all the group separators with |. The following JavaScript function works when I first scan the barcode into Notepad++ and then copy it to the input field, but not when the barcode is scanned directly into the input field. What's the problem?
var barcode = document.getElementById('barcode').value;
barcode = barcode.replace(new RegExp(String.fromCharCode(29), 'g'), '|');
alert(barcode);