Issue
I have an input field and also i need to stop the user from typing more than the allowed character.
<input type="text" name="callsign" maxlength="7" >
It is working in browser.But not working on android devices?
Solution
Thanks for all your answers.Your answers didn't me a give a proper solution.Then i have created a directive for that.
directive.js
myApp.directive('limitChar', function() {
'use strict';
return {
restrict: 'A',
scope: {
limit: '=limit',
ngModel: '=ngModel'
},
link: function(scope) {
scope.$watch('ngModel', function(newValue, oldValue) {
if (newValue) {
var length = newValue.toString().length;
if (length > scope.limit) {
scope.ngModel = oldValue;
}
}
});
}
};
})
html
<input type="text" limit-char limit="7" >
Answered By - Muhsin Keloth
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.