Reputation: 3359
I have function to remove symbols from a text. How to keep commas and dots ( . , ) in text field? Becouse at the moment function remove everithing who is not digits
$('.numbersOnly').bind("keyup paste", function(){
setTimeout(jQuery.proxy(function() {
this.val(this.val().replace(/[^0-9]/g, ''));
}, $(this)), 0);
});
Upvotes: 1
Views: 90
Reputation: 93
Change to:
$('.numbersOnly').bind("keyup paste", function(){
setTimeout(jQuery.proxy(function() {
this.val(this.val().replace(/[^0-9\.\,]/g, ''));
}, $(this)), 0);
});
Upvotes: 1
Reputation: 11721
Try below code :-
$('.numbersOnly').bind("keyup paste", function(){
setTimeout(jQuery.proxy(function() {
this.val(this.val().replace(/[^0-9.,]/g, '')
}, $(this)), 0);
});
Upvotes: 2