angularjs - ng-pattern always shows error why? -
i have following code.
<input name="fname" type="text" ng-init="vprof.fname = '<?php echo $this->general["fname"]; ?>'" class="form-control" placeholder="first name" ng-model="vprof.fname" ng-minlength="3" ng-maxlength="100" ng-pattern="/^[a-za-z]$/"> <p ng-show="generalform.fname.$error.minlength && !generalform.fname.$pristine" class="help-block">your first name should minimum 3 character</p> <p ng-show="generalform.fname.$error.maxlength && !generalform.fname.$pristine" class="help-block">maximum 100 characters allowed</p> <p ng-show="generalform.fname.$error.pattern && !generalform.fname.$pristine" class="help-block">only alphabets allowed</p>
if type alphabet character shows error why?
your pattern has problem subtle change that. please change ng-pattern="/^[a-za-z]+$/"
i have created plnkr link same plnkr
Comments
Post a Comment