Input mask with JQuery and regexp
I'm looking for a Javascript or JQuery solution (client side) to :
- Mask input: prohibit the user to enter an illegal character
- Accept regexp like
^[-+]?[0-9]+(\.[0-9]+)?
- Accept regexp like
- Format the input
- thousands separator=
, - decimal separator=
.
- thousands separator=
For example, I want 1234.56 to be display (change to) '1,234.56`.
Masked Input Plugin can't allow the formatting (I can't tell it [0-9]+ before the decimal separator).
meioMask allows 999.999.999.999,99 format, but the value is converted to string. The binding with Dou开发者_JS百科ble in Java fails.
Do you have proposals, areas of research?
I followed the advice of Ayman Safadi and I've used plugins.jquery.com/project/numberformatter to format and parse the input.
I store the value entered in the alt field and restore to the value when the user focus (and format onBlur).
This solution does not block the entry (eg prevent type a letter in an amount). Any other ideas should be appreciate.
加载中,请稍侯......
精彩评论