layui input 输入框 判断小数点问题

timo-nbktp 1年前 ⋅ 633 阅读
只允许输入数字(整数:小数点不能输入)

<input type="text" onkeyup="value=value.replace(/[^\d]/g,'')" >

允许输入小数(两位小数)

<input type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,2})?).*$/g, '$1')" >

允许输入小数(一位小数)

<input type="text" onkeyup="value=value.replace(/^\D*(\d*(?:\.\d{0,1})?).*$/g, '$1')" >

开头不能为0,且不能输入小数

<input type="text" onkeyup="value=value.replace(/[^\d]/g,'').replace(/^0{1,}/g,'')" >

 

 

--end----

 

 

 

版权 本着开源共享、共同学习的精神,本文转载自 https://blog.csdn.net/SuperChen12356/article/details/119806179 , 如果侵权之处,请联系博主进行删除,谢谢~