html input的type设置为number后可以输入e

来源:互联网 发布:用js怎么写九九乘法表 编辑:程序博客网 时间:2024/05/20 18:51

正常情况下e不是数字所以不能被输入,原因是e在数学上代表2.71828,所以它也还是一个数字

//加上这段代码<input type='number' onkeypress='return( /[\d]/.test(String.fromCharCode(event.keyCode) ) )' />