I installed autoNumeric and use in my laravel 5.7/ blade / jQuery v3.3.1 / Bootstrap v4.1.2 app, but I failed to set resrictions on only positive decimals(that is money field, different currencies, not only $ or euro).
Reading this https://github.com/autoNumeric/autoNumeric these rules seems rather complicated. I tried as
new AutoNumeric('#money_field', {
currencySymbolPlacement: 'p',
currencySymbol: ‘ PND’,
maximumValue: '9999999999.99',
numericPos : 0.01
});
But failed, as negative value can be entered. Which is the valid way ?
Thanks!
The documentation is very unclear but looking at the source you can see that numericPos
is actually a set of predefined options (not an option in itself): https://github.com/autoNumeric/autoNumeric/blob/403cf92366976a1c5df6689074242957e6f9c118/src/AutoNumericPredefinedOptions.js#L216
The one you need is minimumValue
.
new AutoNumeric('#money_field', {
currencySymbolPlacement: 'p',
currencySymbol: ' PND',
maximumValue: '9999999999.99',
minimumValue: 0
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/autonumeric/4.1.0/autoNumeric.min.js"></script>
<input id="money_field" />