Reputation: 9614
I have this input mask FIDDLE:
<input data-inputmask="'mask':'[[[[[9]9]9].9]9]9,--€','greedy':false,'numericInput':true" />
but I do not want thousand separator (dot) to be visible until user types in 4th digit. So, currently the input is:
1,--€
14,--€
.145,--€
1.450,--€
What I need is logical:
1,--€
14,--€
145,--€
1.450,--€
Other mask I tried does not allow 4th digit at all:
[[[[[9]9]9.]9]9]9,--€
Currently I use simple mask:
999.999,--€
...but I do not want complete mask to be visible ___.___,--€
Is there a way to do this with current library? Also, first number should not be zero, maybe regex is better solution.
Upvotes: 0
Views: 4840
Reputation: 46
Your best bet may be to override the "numeric" alias, as follows:
<html>
: <!-- includes etc. -->
<script>
$(document).ready(function(){
$("#price").inputmask();
});
</script>
</head>
<body>
Price: <input id="price" data-inputmask="'alias': 'numeric', 'groupSeparator': '.', 'autoGroup': true, 'digits': 2, 'digitsOptional': true, 'radixPoint': ',', 'suffix': ' €', 'placeholder': '0', 'min': '0', 'max': '99999'" />
</body>
</html>
The options should be fairly self-explanatory, you can modify as needed. This differs from your problem in that cents are optional (and not always excluded). You may want to read a bit of the code, especially jquery.inputmask.numeric.extensions.js, from which you may learn somewhat. There is also an "integer" alias, which might work for what you want (adjusting suffix), but it does seem to have a bug.
Upvotes: 3