Angular 4 Form Validators - minLength & maxLength does not work on field type number

前端 未结 12 1025
被撕碎了的回忆
被撕碎了的回忆 2021-01-03 18:06

I am trying to develop a contact form, I want user to enter phone number values between length 10-12.

Notably same validation is working on Message

12条回答
  •  难免孤独
    2021-01-03 18:27

    You should not use length here, for min and max use custom validator like this,

    var numberControl = new FormControl("", CustomValidators.number({min: 10000000000, max: 999999999999 }))
    

    Angular2 min/max validators

提交回复
热议问题