最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
完美解决input[type=number]无法显示非数字字符的问题
时间:2022-06-25 14:24:25 编辑:袖梨 来源:一聚教程网
在移动端webview实现的页面中,有数字的地方必须使用input type="number"类型的input,否则触发后的键盘为全键盘,而非数字键盘。但另外的一个问题是,input 为 type="number" 类型的无法显示非数字字符,比如:12/23中/。
只能采取另外的思路来解决,比如:显示的时候用非number类型的input或其它元素,当触发onfocus后,利用js 动态修改为number类型。
| 代码如下 | 复制代码 |
varoPage = document.querySelector('#pageNum'), oTotal = document.querySelector('#totalPage'), sOldVal ='';
oPage.addEventListener('focus',function() { this.type ='number'; sOldVal =this.value; },false);
oPage.addEventListener('blur',function() { varsVal =this.value; this.type ='text'; if(sVal != sOldVal) { this.value +='/'+ oTotal.value; } },false); | |
相关文章
- 污污漫画入口风险警示-合规访问指南与安全指引 12-13
- 海棠文学城网页版官网入口-2025在线网址直达 12-13
- 土豪漫画官方APP免费下载入口-正版无广告畅读保障 12-13
- 歪歪漫画app最新版下载入口-首页畅读无广告直接进 12-13
- SkrBT磁力官网最新入口-skrbt磁力引擎极速版入口 12-13
- 微博热搜网页版极速入口-微博热搜榜官方直达链接 12-13