angularjs - ng-pattern directive mess up input's capability -


i need validate ng-pattern security code has 4 digits. after add ng-pattern="/^[0-9]{4}$/" input fails display model attribute (security code). if remove ng-pattern form , input works no validation. how fix it?

http://jsbin.com/saroyo/1/

updated 1 error visible

var app = angular.module('myapp',[]);  app.controller('myctrl',function($scope){    });
</script>  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>  <div ng-app="myapp">  <div ng-controller="myctrl">  <form name="myform">      code: <input type="number " name="code" ng-model="user.code"        ng-minlength="4" ng-maxlength="4">      <span class="error" ng-show="myform.code.$error.minlength">        should 4 charachters long</span>      <span class="error" ng-show="myform.code.$error.maxlength">        should 4 charachters long</span><br>      <span class="error" ng-model="user.code" ng-show="(user.code === parseint(user.code, 10)) && (myform.$dirty === true) && (myform.code.$error.minlength == false) && (myform.code.$error.maxlength == false)">        should have integers</span><br>    </form>  </div>  </div>


Comments

Popular posts from this blog

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -