Pattern is not working for Positive Integer number in Angular 4 form builder

1k Views Asked by At

I am using Angular 4 and Reactive form (using form builder), I have one field in my form name Quantity of Products so we know that quantity does not contain Nagative value and floating value, please suggest me right pattern for that

<input type="number" formControlName="quantity" class="form-control">

 this.myForm = this._fb.group({
    quantity: ['', [Validators.pattern(/^[+]?[1-9]\d*$/)]],
    });

I don't want to allow user to enter nagative value, zero, dot(.) and any other syboles like - and e.

I want only positive + Integer (whole number)

Thanks in advance please help me

0

There are 0 best solutions below