I used the below function to auto adding comma in text box (Such as: 124355 => 124,355)
function addCommas(num) {
return num.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
And I use onKeyUp
event:
<td><input type="text" onkeyup="this.value=addCommas(this.value);"/></td>
If I enter the number quickly this is ok. But, if I enter number slowly I got the below result:
124355 => 1,2,4,355
135298532 => 1,3,5,2,9,8,532
Can you help me fix this ?