Form input field value replace onchange with jQuery

2014-09-21 • Snippets • Views: 1449

Form input field value replace onchange with jQuery

If someone put text into an input field (or automatic e.g. with a 2d barcode scanner) and you want to replace a part of the input (pattern) then will help this small jquery code snippet.

[php]
<input name="field" id="field" type="text" value="" class="delprefix">

<script type="text/javascript">
$(document).ready(function() {
$(‘.delprefix’).change(function() {
var value = $(this).val();
//alert(value);
$(this).val(value.replace(/00040E-/i, ”));
});
});
</script>
[/php]

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Shares