扫码关注官方订阅号
我的input标签的类型是text,需要在里面只能输入数字,而且最大是10,不用正则表达式,要怎么实现
业精于勤,荒于嬉;行成于思,毁于随。
<input type="number" name="points" min="1" max="10" />
参考:http://www.w3school.com.cn/tiy/t.asp?f=html5_form_number
2015年12月24日 14:00:28 更新
<input type="text" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength = 1>
收工。
我觉得还是正则好多了。
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
<input type="number" name="points" min="1" max="10" />参考:http://www.w3school.com.cn/tiy/t.asp?f=html5_form_number
2015年12月24日 14:00:28 更新
<input type="text" onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength = 1>收工。
我觉得还是正则好多了。