I want to add comma to numbers every three digits on Textboxes.
I’m using this code but it not works.
Where am I wrong?
$(function () {
$.fn.digits = function () {
return this.each(function () {
$(this).val($(this).val().replace(/(\d)(?=(\d\d\d)+(?!\d))/g, "$1,"));
})
}
$("#Test").bind("change keyup keydown paste blur", function (e) {
$("#Test").digits();
});
});
Try the following:
JSFiddle http://jsfiddle.net/BrUVq/1/