javascript - regex pattern for max length 12 -


i need regex pattern max length 12 , should not accept 0 if entered user.

my current pattern not working. here is:

[0-9]{0,12} 

any suggestions welcome , explanation of pattern.

^[1-9]{0,12}$ means 12 digits (excluding 0), left emtpy allowed.

if field required, change minimun 1, ^[1-9]{1,12}$

and way, ^ , $ means start , end of input string.

if regexp [1-9]{1,12}, without ^ , $, "abc123def" allowed because center part 123 matched.


Comments

Popular posts from this blog

javascript - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -