Reputation: 9687
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,
Upvotes: 1
Views: 838
Reputation: 953
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
Upvotes: 4