Justin McClain Justin McClain - 3 months ago 14x
AngularJS Question

How to use ng-pattern to limit 10 number inputs separated by comas

Okay so I'm stuck right now,

I want to enter in up to 10, 8 character length numbers in one text field all separated by commas. For example, 12345678,12345678,12345678,12345678.....

The only thing is the numbers can only be 8 characters at max and only up to 10 numbers entered at max. I have it to where I can keep entering numbers but I cannot get it to be with those limitations and I need help.

This is what I have right now: ng-pattern="/^([0-9\s])+(,[0-9\s]+)*$/"

Oli Oli

Try this pattern:


And works as follows, first, require 1-8 digits, optionally, require comma, 1-8 digits 0 to 9 times.