the task looks simple. I have to remove non-numeric characters from an input field of type "number" on keyup in firefox.
The code:
$("#field").on("keyup", function() {
regex = /[\\D]+/;
$(this).val( $(this).val().replace(regex, '') );
});
Unfortunately as soon as a non-numeric character enters the field, its whole content gets replaced by the empty string.
For example:
234d = emptied > should be 234
Solution (here because the question has been closed):
This example works. I found out that it has to do with the field type. If the input in the field of type "number" contains non numeric characters, firefox shows the input but doesn't store it in the input object. As soon as I use a text input everything works fine. Seems to be a Firefox issue.
I think this question is NOT duplicate because it seems to regard a Firefox issue with input fields of type "number".