I have put this code on my file :
if(autoNumericArray[$(this).attr('personne')] === undefined)
{
autoNumericArray[$(this).attr('personne')] = new AutoNumeric(this, {digitGroupSeparator : '', decimalCharacter : '.', overrideMinMaxLimits: 'ceiling', decimalPlaces: 2, watchExternalChanges: true, invalidClass: 'red' , eventIsCancelable: false, failOnUnknownOption: true, onInvalidPaste: 'ignore', showWarnings: false, maximumValue : valMax, minimumValue : valMin, roundingMethod : 'N05', upDownStep: '0.05'});
autoNumericArray[$(this).attr('personne')].node().addEventListener("change", function(data){
if(autoNumericArray[$(this).attr('personne')].getNumber() < $(this).attr('min') || autoNumericArray[$(this).attr('personne')].getNumber() > $(this).attr('max'))
autoNumericArray[$(this).attr('personne')].set($(this).attr('min'));
});
}
else
{
autoNumericArray[$(this).attr('personne')].update({digitGroupSeparator : '', decimalCharacter : '.', overrideMinMaxLimits: 'ceiling', onInvalidPaste: 'ignore', showWarnings: false, maximumValue : valMax, minimumValue : valMin, roundingMethod : 'N05', upDownStep: '0.05'});
}
I tried to create dynamically some Autonumeric object in a loop and save it in a JS Array.
But I have a some trouble here.
- the number are never formated with 2 digits after the separator when we change the value in the input field.
- with the option
failOnUnknownOption
to true, I have an error thatinvalidClass
isn’t defined even I have add it as an option - The addEventListener change is never called. I really don’t know why. And I don’t have any other way to check if the value is valid or not
I use the last version of https://autonumeric.org/
Is some one has any idea why I have those trouble ?
Thank you for your help