jQuery只能输入数字
第一种写法:
<input onkeyup="value=value.replace(/[^\d]/g,'')" />
第二种写法:
<input id="money1" onkeyup="Convert()" /> function Convert() {
var bb = $("#money1").val();
$("#money1").val(bb.replace(/[^\d]/g, ''));
}
jQuery只能输入money
function checkPrice(price) {
return (/^(([1-9]\d*)|\d)(\.\d{1,2})?$/).test(price.toString());
} if(!checkPrice($("#money").val())) {
alert("付款金额格式不对!");
return;
}
参考