I want to validate a 9 digits number using angular,
this is in my modal :
<input type="number" class="form-control" ng-model="id" required>
i tried pattern = [0-9]{9}, seems its passing every number that its getting . I want to pass only number 000000000 - 9999999999 , min-max also not working for me.
this is what my app adding to this class:
class="form-control ng-pristine ng-valid-number ng-invalid ng-invalid-required"
thank u !
I just use a pattern
as validator. The following code will make the field required
and must be only digits
of length 10
ngOnInit() {
this.firstForm = this.fb.group({
firstCtrl: ['', [Validators.pattern('^[0-9]{10}$'), Validators.required]],
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With