I need to replace all non numeric characters in a textare using javascript. Our client wants to remove and non digits e.g 1,330.00 becomes 1330.00.
I can replace all non digits except for the decimal place, but this allows multiple decimal places.
I have a jsbin of the code http://jsbin.com/vetedeca/1/edit?html,output
$(document).ready(function(){ $('input').bind('keyup', function() { var value = $(this).val() value = value.replace(/[^\d\.]+/g,''); $(this).val(value); }) })
How can i edit this to remove all non digits except the first occurrence of a decimal place
e.g 1,330.00 becomes 1330.00 1,330.00.00 becomes 1330.00 133o.00d.33 becomes 133.00