Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Number Formatting (input mask) in jQuery

I'm trying to format numbers in a text field like so:

123,456,789

I know that there are a lot of jQuery plugins to do this, however, they all change the actual value. I just want it to look formatted, and not be sent formatted.

For example, if I type in 23845 into my text field, I want it to visually convert to 23,845, but when I send the form I want it to send as 23845.

Does anyone know how I can achieve this? All other solutions I've seen change the actual submitted value.

like image 714
blitzmann Avatar asked Jun 29 '11 07:06

blitzmann


1 Answers

AFAIK, the masks plugin do not change the value but only the display : http://plugins.jquery.com/plugin-tags/mask

[edit] within the list of all the plugins, i've used this one on my code : https://github.com/RobinHerbots/jquery.inputmask ([edit 2] and worked as you want i've checked the code where i used it and the default behavior is that it sends the mask with the value, you need to use an option to unmask as i've said in my comment)

like image 91
JMax Avatar answered Oct 05 '22 19:10

JMax