Setting the input `value` directly with Javascript without using the `set()` method is not supported
See original GitHub issueExpected behavior
To be able to fill an input field’s value with jQuery’s val function.
Actual behavior
Sadly, it does not work with AutoNumeric 4. And I can not call any trigger on the field to store (or even just parse) the value which was loaded to the input by the val function. I have several AutoNumeric fields and it would be a huge (and risky) work to refactor all value set from this:
$('#autonumeric_field1').val('60100').trigger('blur');
to this:
AutoNumeric.getAutoNumericElement($('#autonumeric_field1').get(0)).set(60100);
The first one was worked with AutoNumeric 1.9.
The main problem isn’t that it not formatting the value anymore but it doesn’t even store the value. If I set it with jQuery’s val, then I move the cursor to the field and move it out, the AutoNumeric restore the previous value to the field. It is a very, very dangerous behavior. The user can belive that the new value will be submitted but it isn’t if the AutoNumeric restore its value.
Steps to reproduce the problem
- Using autoNumeric
4.0.3
and the browserChrome
version61.0.3163.100 (Official Build) (64-bit)
onWindows 10
, - Set the field’s value with jQuery’s val function
- Move the cursor above the field then move it out.
Link to live example
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (7 by maintainers)
Top GitHub Comments
For info, static
set()
andget*()
functions are now available inv4.1.0-beta.12
.For info you can now use:
directly without having to first select the DOM element. This has been fixed in #514.