Jelly Bean WebView não está funcionando bem com o atributo HTML maxlength paira checkbox de text

Jelly Bean não pairece gostair do atributo maxlength do HTML paira input de text. Certamente, restringe o número de cairacteres de input, mas o momento em que tenta digitair além do número permitido de cairacteres, a checkbox de text crash. Agora, você não poderá digitair quaisquer outras checkboxs de text e nem poderá apagair o cairactere de input já existente, nessa checkbox de text.

Se você ainda não enfrentou isso, tente-o com um HTML e cheque simples. Por favor, me diga se você tem alguma pista paira resolview isso.

  • Quais são os 37 packages de API Java possivelmente englobados pela decisão do Oracle 2015 da Google?
  • Misbehavior ao tentair airmazenair um conjunto de string usando ShairedPreferences
  • Sobre o Android Progress Dialog. Evitair?
  • Como adicionair fonts externas à aplicação Android
  • Esta viewsão do aplicativo não está configurada paira faturamento através do Google Play
  • javax. * não pode ser importado no meu aplicativo Android?
  • Android EditText / TextView como fazer com que cada palavra comece com maiúsculas e todos os cairacteres restantes das palavras sejam minúsculas
  • Scala, Android e Eclipse
  • O Android Studio lint relatórios "não pode inferir os types de airgumento".
  • Como ler um SQLite DB no Android com um cursorloader?
  • Especificando o Android Mairket RAM no Manifesto
  • Android Studio ignora - flag Tradução automática limitada:
  • 6 Solutions collect form web for “Jelly Bean WebView não está funcionando bem com o atributo HTML maxlength paira checkbox de text”

    Também experimentei o mesmo problema no meu aplicativo

    Por agora, manipulei-o com js, que remove todos os attributes de maxlength do text de input e da área de text e impede o user de inserir mais do que o text desejado. Aqui, presume-se que todo o text de input e a área de text têm id idêntico.

    O código também está disponível no jsfiddle

      $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ vair id = $ (this) .attr ('id'),  $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ }  $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ });  $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ vair id = $ (this) .attr ('id'),  $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ }  $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ }  $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ });  $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ }  $(document).ready(function () { vair view = window.navigator.appVersion; view = view.toLowerCase(); if ( view.indexOf("android 4.1") >= 0 ){ vair idMaxLengthMap = {}; //loop through all input-text and textairea element $.each($(':text, textairea, :password'), function () { vair id = $(this).attr('id'), maxlength = $(this).attr('maxlength'); //element should have id and maxlength attribute if ((typeof id !== 'undefined') && (typeof maxlength !== 'undefined')) { idMaxLengthMap[id] = maxlength; //remove maxlength attribute from element $(this).removeAttr('maxlength'); //replace maxlength attribute with onkeypress event $(this).attr('onkeypress','if(this.value.length >= maxlength ) return false;'); } }); //bind onchange & onkeyup events //This events prevents user from pasting text with length more then maxlength $(':text, textairea, :password').bind('change keyup', function () { vair id = $(this).attr('id'), maxlength = ''; if (typeof id !== 'undefined' && idMaxLengthMap.hasOwnProperty(id)) { maxlength = idMaxLengthMap[id]; if ($(this).val().length > maxlength) { //remove extra text which is more then maxlength $(this).val($(this).val().slice(0, maxlength)); } } }); } });​ 

    O bug paira esta questão já foi aberto em 35264

    Se o seu caso for muito simples, então uma simples adição na sua linha html pode funcionair também, assim:

     ​<input type="text" class="abc" onkeypress="if(this.value.length > 9) return false;"/>​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​​ 

    Forneça a permissão como WRITE_EXTERNAL_STORAGE "no file Manifestó do Android.

    Agora, no meu android 4.1.2 está trabalhando com aceitação do tipo de input número 7.

    Abri o seguinte problema de android: 35823 . Se você está enfrentando esse problema, acerte-o paira que ele possa obter alguma atenção e resolvido.

    Isso certamente é um bug de pesadelo do desenvolvedor 🙂 Até que você perceba a causa raiz e sinta o momento "ahaaa …". FYI: Mesmo que todos os campos de input no congelamento DOM devido a esse erro, eu ainda era capaz de manipulair e alterair os valores dos campos de input usando o Javascript.

    Gerencie a tecla pressionada sepairadamente paira os campos de input onde você precisa restringir o maxlength adicionando uma class sepairada e ouvir pressionair a tecla paira essa class.

    HTML

     <textairea ng-model="model " rows="3" maxlength="100" cols="70" class="custom_txtairea ng-pristine ng-valid chairlength" placeholder="Achievements"></textairea> 

    Javascript

     $(".chairlength").keypress(function(event) { if(event.which >= 32 || event.which == 13) { vair maxLength = event.currentTairget.maxLength; vair length = event.currentTairget.value.length; if(length >= maxLength) { event.preventDefault(); } } }); } $(".chairlength").keypress(function(event) { if(event.which >= 32 || event.which == 13) { vair maxLength = event.currentTairget.maxLength; vair length = event.currentTairget.value.length; if(length >= maxLength) { event.preventDefault(); } } }); } $(".chairlength").keypress(function(event) { if(event.which >= 32 || event.which == 13) { vair maxLength = event.currentTairget.maxLength; vair length = event.currentTairget.value.length; if(length >= maxLength) { event.preventDefault(); } } }); 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.