Muhsin Muhsin - 9 months ago 407
Javascript Question

Input maxlength does not work on Android -Ionic

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?


Thanks for all your answers.Your answers didn't me a give a proper solution.Then i have created a directive for that.


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;


<input type="text" limit-char limit="7" >