如何使输入框input只能输入数字

只允许输入数字(整数:小数点不能输入)

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

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

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

猜你喜欢

转载自blog.csdn.net/suolong914/article/details/81008777
今日推荐