限制input只能输入数字/数字和小数点

1.限制input只能输入数字

<input id="Number" name="Number" type="text" class="form-control required" onkeyup="value=this.value.replace(/\D+/g,'')" placeholder="请输入数量" />

2.限制input只能输入数字和小数点(用于金额输入框等)

<input id="Price" name="Price" type="text" class="form-control" onkeyup="value=value.replace(/[^\d{1,}\.\d{1,}|\d{1,}]/g,'')" placeholder="请输入单价" />

 

posted @ 2017-08-04 16:31  圆圆娃哈哈  阅读(6892)  评论(0编辑  收藏  举报
Live2D