JSN*_*nja 2 html javascript html5 android cordova
我正在尝试在android cordova 3.5.0应用程序中实现一个输入字段,如下所示:
<input type="text" maxlength="7" class="form-control" placeholder=" "/>
Run Code Online (Sandbox Code Playgroud)
但是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;
}
}
Run Code Online (Sandbox Code Playgroud)
html如下:
<input type="text" maxlength="7" class="form-control" onkeyup="checkTestPressure(this);" onblur="trimWhiteSpacesForTextBox(this);" id="testpressure" placeholder=" ">
Run Code Online (Sandbox Code Playgroud)
这首先工作,但如果我在7位数后继续点击键盘上的键,输入文本字段变空并开始重新填充,因为我一直按下键.
这是不可接受的,我只想要前7个字符,无论我按键盘上的键多少次都不应填充字段.
上面的代码在桌面上的浏览器中工作正常但在我在cordova android应用程序中运行时给出了上面提到的问题.
任何帮助表示赞赏.
提前致谢.
有点晚了,但您可以使用此属性来完成禁用文本更正/修改.
<input
autocomplete="off"
autocorrect="off"
autocapitalize="off"
spellcheck="false">Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3631 次 |
| 最近记录: |