google chrome - AngularJS custom validation directive: cursor jumps to end of string -
i wrote custom angularjs directive dynamically adds ng-pattern , other stuff. it works, in chrome , internet explorer, if user tries enter chars in middle of existing string, cursor jumps end of string. in firefox works fine. (tested chrome 44, firefox 40, ie 11) html: <input type="text" name="input1" ng-model="value1" validation-directive> js: myapp.directive("validationdirective", function ($compile) { return { restrict: 'a', link: function (scope, element) { element.removeattr('validation-directive'); // necessary avoid infinite compile loop element.attr("ng-pattern", new regexp("^[a-z]{0,10}$")); //do more stuff... $compile(element)(scope); } }; }); http://jsfiddle.net/y8416aax/ why happened? , can fix that? thanks! basically need remove directive attribute , add ng-pattern attribute compile...