I am using regEx /^[0-9]+((?:[,][0-9]{0,20})?)$/g
.in this I am able to enter digit,digit. but i want to add more digit.
I have created sample app on Stackblitz
For example digit, digit,...nth number.
Valid inputs:
1234567890
123,321,467,56,1
Invalid inputs:
1123,,456
,123,456,
123,
Try below regex. Demo is here .
^(\d+\,?)*\d+$
Edit: Do the following changes in your project.
commaSeperatedRegEx = /^(\\d+\\,?)+$/g;
in your appPhoneNumber
directive and const matches = control.value.match(/^(\\d+\\,?)*\\d+$/g);
in app.component
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.