![](/img/trans.png)
[英]maxlength of input tag with type=text using html5 in android webview not working
[英]maxlength not working in input type text in cordova android app
我正在嘗試在android cordova 3.5.0應用程序中實現輸入字段,如下所示:
<input type="text" maxlength="7" class="form-control" placeholder=" "/>
但是maxlength根本不起作用。
我嘗試使用javascript進行以下工作:
function checkTestPressure(txtBox){
if(txtBox.value.length > 7){
console.log(" txtBox = "+ txtBox.value.length);
var str = txtBox.value;
str = str.substr(0,7);
txtBox.value = str;
}
}
html如下:
<input type="text" maxlength="7" class="form-control" onkeyup="checkTestPressure(this);" onblur="trimWhiteSpacesForTextBox(this);" id="testpressure" placeholder=" ">
這首先起作用,但是如果我在7位數字后繼續點擊鍵盤上的鍵,則輸入文本字段將為空,並隨着我不斷按下鍵而開始重新填充。
這是不可接受的,並且無論我按鍵盤上的鍵多少次,我都只希望前7個字符,並且該字段中都不應填充任何內容。
上面的代碼在桌面上的瀏覽器中運行良好,但是當我在cordova android應用程序中運行時卻出現了上面提到的問題。
任何幫助表示贊賞。
提前致謝。
有點晚了,但是您可以使用此屬性來完成禁用文本更正/修改的功能。
<input autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.