限制html文本框input只能输入数字和小数点 代码: <input type="text" class="txt" name="qty" value="" onkeyup="this.value=this.value.replace(/[^0-9.]/g,'')" />