简体   繁体   中英

ng-keyup does not detect android backspace

I'm trying to use ng-keyup in my application, but there's a problem on android backspace.ng-keyup doesn't seem to detect the android backspace. How can i fix this? I want to show a error message if a number is started with "3" max length of tht number should be 15. if else can allow 16.

html

<div class="form-group" ng-class="{ 'has-error' : submitted && (thirdPartyForm.beneAcc.$pristine || thirdPartyForm.beneAcc.$invalid )}">
    <label  class="labelColor"><h5><b>Beneficiary Account/Card Number*</b></h5></label>
    <input  ng-keyup="validateCreditCard();" ng-disabled="data.origin.account == ''" onkeypress="return ((event.charCode > 64 && event.charCode < 91) || (event.charCode > 96 && event.charCode < 123) || event.charCode == 8 || event.charCode == 45 || event.charCode == 32 || (event.charCode >= 48 && event.charCode <= 57))" type="text"  id="beneAcc" name="beneAcc" ng-model="data.beneAcc" class="form-control"  ng-blur="validateDesitinationAccount(data.origin, data.beneAcc);" required>
    <span class="help-inline" ng-show="submitted && (thirdPartyForm.beneAcc.$pristine || thirdPartyForm.beneAcc.$invalid )">Beneficiary Account No cannot be left blank.</span>
    <span class="help-inline" ng-show="validateAccFlag" style="color:red" >{{validateMsgStr}}</span>
    <span class="help-inline" style="color:red;"  ng-if="LkrValidation">You cannot transfer Sri Lankan Rupees to foreign currency accounts.</span>
    <span class="help-inline" style="color:red;"  ng-show ="accountNoFlag">{{accountNoValidateMsg}}</span>
</div>

It shows the error message successfully but the problem is if i delete a number using backspace, the validation won't disappear.

NOTE: android backspace works when i'm typing characters But do not work when i type numbers.

I was also facing the same issue. I used ng-change instead of ng-keyup/ng-keydown and it worked for me. Hope it helps you too.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM