javascript - Input field not updating with ng-keydown event -
in piece of code want add validation input field, if value 0 don't know why not able update , enter new value in input field. not able change input field value.
value remain same if delete existing value , add in existing value.
here html code:
<input ng-model="lineitemdetailsctrlas.lineitems.orderedquantity" type="text" class="col-md-6 text-right panel-row-spacing" ng-keydown="valuechanged($event)" required />
and angular code is:
$scope.valuechanged = function (event) { var quantityrequire={}; if (event.keycode === 48 || lineitemdetailsctrlas.lineitems.orderedquantity == 0) { quantityrequire = { "messageid": "ordered_quantity", "params": [], "severity": "error" }; lineitemdetailsctrlas.errormessages.push(quantityrequire); } else{ event.preventdefault(); } };
you stopping event "event.preventdefault();", because keycode 48 (only number 0) acceptable others keyevents falling down on else condition , stop updating input value.
Comments
Post a Comment