Adding Comma While Typing In The Text Box
I have a text field. I am writing numbers in the text box. While I am writing I want to add the thousand separator. I found this solution: HTML: ).keyup(function(event) {
// skip for arrow keysif(event.which >= 37 && event.which <= 40) return;
// format number
$(this).val(function(index, value) {
return value.replace(/\D/g, "").replace(/\B(?=(\d{3})+(?!\d))/g, ",");
});
});
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><inputtype="text"name= "name1"id="id1"><inputtype="text"name= "name1"id="id2">
Post a Comment for "Adding Comma While Typing In The Text Box"