AngularJS Login form submits partial password -
i using angularjs login form. noticed 1/10 times password being sent partially if user pressed enter key quickly. example, if password "happygolucky", send instead "happy."
i can't seem find similar problem posted elsewhere , @ lost why occurs in first place.
this form using:
<form name="loginform" novalidate ng-submit="loginformdirectivectrl.login()"> <div class="form-group" ng-class="{ 'has-error': loginform.email.$dirty && loginform.email.$error.required }"> <label for="email">company email</label> <input type="text" name="email" id="email" class="form-control" ng-model="loginformdirectivectrl.email" required/> <span ng-show="loginform.username.$dirty && loginform.email.$error.required" class="help-block">company email required</span> </div> <div class="form-group" ng-class="{ 'has-error': loginform.password.$dirty && loginform.password.$error.required }"> <label for="password">password</label> <input type="password" name="password" id="password" class="form-control" ng-model="loginformdirectivectrl.password" required/> <span ng-show="loginform.password.$dirty && loginform.password.$error.required" class="help-block">password required</span> </div> <button class="login-button" type="submit" ng-disabled="loginform.$invalid || loginformdirectivectrl.loading"> <span ng-hide="loginformdirectivectrl.loading">login</span> </button> </form>
what example told in comments creating directive. this.
.directive('inputdelayenter', ['$timeout', function($timeout) { return { require:'^?ngmodel', link: function (scope, element, attrs, ngmodelctrl) { element.bind('keydown keypress', function (event) { if(event.which === 13) { $timeout(500); if(ngmodelctrl.$modelvalue !== undefined){ scope.$apply(function (){ scope.$eval(attrs.coppeldelayenter); }); } } }); } }; } ]);
html
<input type="text" ng-model="data.sku" input-delay-enter>
i think can if change type password.
Comments
Post a Comment