When one of my end users fills out a form then need to use the barcode scanner. An example of the text would be "%247463$1$0$4$20%". My script below is suppose to extract everything after the first two characters up to the last character. It works but it is also showing the original along with it.
<script>
function modify()
{
//Store the value in the field to trim.
var trim = document.getElementsByName("InsertRecordBarcode")[0].value;
//Take a substring of trim and store it back into new trim value.
trim = trim.match("%2(.*)%");
//Set the value of the weight field in the form to the new substring
document.getElementsByName("InsertRecordBarcode")[0].value = trim;
//the new value in the field is what is submitted.
}
//When the form is submitted called method modify.
document.getElementById("caspioform").onsubmit=modify;
</script>
My result showing is "%247463$1$0$4$20%,47463$1$0$4$20". What am I doing wrong as I want it to only show the 47463$1$0$4$20.
thank you.