View Full Version : Removing First Character of a text box before submitting test box to database

09-22-2005, 05:39 PM
Im new to Javascript so I appologies now if this is a easy thing to resolve.

I have a text box that a handheld scanner scans a barcode into. The problem is that the barcodes from the suppiler have an L at the start of the barcode.

Is there a way to remove the first character of a textbox when its inserted into a database.

Many Thanks

09-22-2005, 06:57 PM
Using the substring method for strings would probably be easiest. This is just an example as to how to use it. Not sure how you're submitting the data and such, so this is really just an example rather than the implentation you would like. However, using the server-side language that the form is being submitted to would probably be easier if you're just using the form to submit to the database.

<script language="javascript">
function fixInput()
var myinput = document.myform.scaninput.value;
document.myform.scaninput.value = myinput.substring(2,myinput.length);
<form name="myform">
<input type="text" name="scaninput" size="20" />
<input type="button" name="submitinput" onClick="fixInput()" />