gpt4 book ai didi

javascript - maxlength 在 cordova android 应用程序的输入类型文本中不起作用

转载 作者:太空狗 更新时间:2023-10-29 16:37:02 27 4
gpt4 key购买 nike

我正在尝试在 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 位数字后继续敲击键盘上的键,输入文本字段将变为空,并随着我不断按下键而开始重新填充。

这是 Not Acceptable ,我只需要前 7 个字符,无论我按键盘上的键多少次,都不应填充该字段。

上面的代码在桌面浏览器中运行良好,但是当我在 cordova android 应用程序中运行时出现上述问题。

感谢任何帮助。

提前致谢。

最佳答案

有点晚了,但是你可以使用这个属性来完成禁用文本更正/修改。

<input                                     
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false">

关于javascript - maxlength 在 cordova android 应用程序的输入类型文本中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26010588/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com