Possible bug input number in firefox

3

I was developing a calculation where I used a number field and a text field, where in the number field the user would enter the quantity of an item and the text field would give the value of the item calculated. In some tests performed, when the number field is modified through the field arrows, when resetting the form, the value of the number field is not discarded. Such an error happens only in firefox and only when selecting value one (1). If you enter the number via the keyboard and the form resets, the error does not occur. In this link of JSFIDDLE you can check the error. Is there any way to fix this?

    
asked by anonymous 06.01.2015 / 13:27

1 answer

3

Apparently, when calling the reset method of the form the value of the numeric field is not considered "changed", so when you pass it back to 1 through the arrows, it does not trigger the onchange .

I do not know why this occurs, but a workaround would assign this value to zero before calling the reset:

$(".ve").on("click", function(){ 
   alert('res');
   $("#quantidade").val(0); // O valor não será mais '1'
   $(this).parent().find('form')[0].reset();
});

Example . Q. If you reset the form and use the down arrow, the second field will show NaN . It would be interesting to test for isNaN on change to avoid this.

    
06.01.2015 / 13:39