0
<input oninput="if (this.value.length > this.maxLength)
this.value = this.value.slice(0, this.maxLength);
validity.valid||(value='');" min="0" step="1" type="number"
maxlength="9" formControlName="quantity" class="form-control"
[ngClass]="item.controls['quantity'].errors ? 'has-error' : ''"
(keydown)="onValueOrQuantityChanged(item)"
(keyup)="onValueOrQuantityChanged(item)">
I have the html code above that inserts an input of type NUMBER. Together there is a javascript code that ensures that I do not type more than 9 numbers.
The problem is that when my application runs on Firefox, when typing zero(s) on the left, it is (are) dropped(s) after typing the 9 numbers.
Ex. by typing "000999999", zeros are discarded and I can type you 3 more numbers at the end of the value. But I want to keep these zeros.
OBS.: is happening only in Firefox.
it shows no error in console?
– Alvaro Alves
If it’s not causing any trouble, switch to
type='text'
and see if it solves.– Máttheus Spoo
@Máttheusspoo we are using as a requirement that the field cannot accept character other than number (requirement requested by client)
– Cris.tal
@Alvaroalves no error message
– Cris.tal
@Cris.tal in this case, put a mask on the field, or use a
input.replace(/\D/g, '')
at an eventkeyup
.– Máttheus Spoo
If you want to keep the zeros, because you are using Slice?
– Sam