angularjs regex for positive number of fixed length -


i'm writing validations in angularjs. i've allow 6 digit positive number (6 digit whole number). i'm using following regex isn't working:

"pattern": /^\+?[0-9]+$/ 

it accepting -15 also.

you didn't backslash first plus sign. in regular expressions plus sign means previous element should matched 1 or more times. however, want regular plus, add \ it.

/^\+?([1-9][0-9]{5})$/

if more regular expressions regexr.com great website can learn more , test them in real time.


Comments