Quantcast
Channel: Add commas for a number in input field while typing - Stack Overflow
Browsing latest articles
Browse All 6 View Live

Answer by manroe for Add commas for a number in input field while typing

I tried autoNumeric as @Zero-Distraction 's answer suggested, but I had some issues with cut/pasting into it. The CleaveJS library has a lot more popularity, a little more built-in functionality, and I...

View Article



Answer by Luke for Add commas for a number in input field while typing

I tried to improve on j0k's code by instead using blur and focus events rather than keyup: http://jsfiddle.net/AqDda/ ^ Try input A (standard type="number") versus input B (type="text" with JavaScript...

View Article

Answer by CR41G14 for Add commas for a number in input field while typing

$(document).ready(function(){ $('input.number').keyup(function(event){ // skip for arrow keys if(event.which >= 37 && event.which <= 40){ event.preventDefault(); } var $this = $(this);...

View Article

Answer by XepterX for Add commas for a number in input field while typing

if you wanted to have something like "1 000 000", you can change the code to something like this. var num = $this.val().replace(/(\s)/g, ''); $this.val(num.replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1 "));...

View Article

Answer by Zero Distraction for Add commas for a number in input field while...

You can use Digital Bush's Masked Input Plugin for Jquery. It has many options for customisation including spaces, eg: $("#myInputText").mask("9 999 999",{placeholder:" "}) It seems to have been tested...

View Article


Add commas for a number in input field while typing

This does it incorrectly: Can jQuery add commas while user typing numbers? $('input.number').keypress(function(event){ if(event.which >= 37 && event.which <= 40){ event.preventDefault();...

View Article
Browsing latest articles
Browse All 6 View Live




Latest Images