当我输入任何密码时,它会自动填写密码旁边的文本框中的城市。但是当我按Tab键进入城市的文本框时,它会在该文本框中清除城市。我怎么能阻止这个??
<div class="col-md-3">
<div class="input-group" ng-class="{'error':employeeForm.pin_code.$touched && employeeForm.pin_code.$invalid }">
<span class="input-group-addon">Pincode<span style="color:red">*</span></span>
<input type="text" id="pincode" ng-readonly="contactReadonly" ng-keydown = "user.city = ''" ng-keyup="employeeForm.pincode.$viewValue.length > 5 && search(user.pincode,'city')" name="pincode" maxlength="6" autocomplete="off" ng-model="user.pincode" placeholder="121038" class="form-control digits" required>
</div>
<span ng-show="pincodeError" style="color: red" ng-cloak>{{pincodeErrorMsg}}</span>
</div>
<div class="col-md-3">
<div class="input-group" ng-class="{'error':employeeForm.city.$touched && employeeForm.city.$invalid }">
<span class="input-group-addon">City<span style="color:red">*</span></span>
<input type="text" id="city" ng-change = "cityChangeEvent()" style="text-transform: capitalize;" name="city" class="form-control only_name" placeholder="Your city" ng-model="user.city" required>
</div>
</div>
答案 0 :(得分:2)
您的代码ng-keydown = "user.city = ''"
会将每个keydown-press上的城市输入字段设置为空,当pincode字段处于焦点时,这也包括选项卡。您需要删除这部分代码,或者评估按下的键,如果键是tab,或者您想要阻止的任何其他键,则不执行任何操作。