I’m trying to create a function to remove the first character of the input box if it =P. We use a barcode scanner and it uses a prefix of P, when scanning part numbers I want to strip that out on the fly.
<input id="part" onKeyUp="fixP(this.value);" size="20" type="text" name="part" style="text-transform: uppercase;"/>
<script>
function fixP() {
$('#part').val($('#part').val().substr(1).replace(/P/,""));
}
</script>
This just results in continually removing anything I type in the input.
Any help is appreciated.
Why not hook into the on change event as well? http://jsfiddle.net/SKEwJ/2/