When using input type=number, there is a button to increment/decrement the value at the right of the input field. Can we restrict users from decrementing it to a negative value?
I know we can use min=0 in HTML input element but is there any other way to achieve this using Angular FormControl Validators?
(I can't use min=0 because the input element can be either number or text and this input is used in many places).
I'm trying to add Validators if the condition is match with the input. (e.g if (formInput.type === 'number') { formControl.addValidators(Validators.min(1)); }
I tried Validators.min(1) in FormControl but it still allows user to go past 0 when clicking the decrement button in input type=number field.
Thank you.
Validators.pattern(your_regex)