【发布时间】:2015-11-25 07:11:25
【问题描述】:
<input type="text"
ng-model="emp.eedKey007"
ng-keypress="nonNumericInput($event)" >
移动应用程序的输入文本字段(应用程序正在使用 ionic 和 angularjs ),它与控制器中的 $scope.emp.eedKey007 映射。 我想让这个文本字段不是数字的。如果用户想要插入任何数值,他将无法在 text Field(MOBILE)
中输入$scope.nonNumericInput = function ($event) {
console.log("key presed");
$scope.showFixAlert = function() {
var alertPopup = $ionicPopup.alert({
title: $translate('Info'),
template: $translate('Invalid Input ...')
});
};
var charCode = $event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
console.log("Character is pressed");
} else {
$scope.showFixAlert();
/**/ what code should i need to use here so that i can restrict numeric value inserted in text field.**
// in below code i try to replace the numeric character with blank character. which is assigned in eedKey007 but its not working correctly . I can't blank the textfield on numeric value insertion.
var StringLang = $scope.emp.eedKey007;
$scope.emp.eedKey007 = StringLang.replace(StringLang.slice(-1),'');
}
}
【问题讨论】:
标签: javascript angularjs jquery-mobile ionic-framework