I am using jQuery Mask Plugin in my web project. It is used widely and I don't want to change it for now.
I use the following mask for the numbers with decimal separators:
For example for the element:
<input class="number-field" value="123456">
I use the following mask:
$('input.number-field').mask('#,##0', {'reverse': true});
It works for positive numbers, but now I would like to add support of negative numbers.
Neither of the following patterns work:
$('input.number-field').mask('#,##0Z', {
reverse: true,
translation: {
'Z': {
pattern: /\-?/
}
}
})
$('input.number-field').mask('Z#,##0', {
reverse: true,
translation: {
'Z': {
pattern: /\-?/
}
}
})
$('input.number-field').mask('Z#,##0', {
reverse: true,
translation: {
'Z': {
pattern: /-/,
optional: true
}
}
})
Last one seems working, but only for 4 digits in the line.
How can I use this plugin for negative numbers? I may consider even patching this plugin if someone can propose an idea.
You can try it with jsFiddle template