Form input field value replace onchange with jQuery


/ Published in: jQuery
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  1. <input name="field" id="field" type="text" value="" class="delprefix">
  2.  
  3. <script type="text/javascript">
  4. $(document).ready(function() {
  5. $('.delprefix').change(function() {
  6. var value = $(this).val();
  7. //alert(value);
  8. $(this).val(value.replace(/00040E-/i, ''));
  9. });
  10. });
  11. </script>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.