<input id="cashMoney" type="number" maxlength="10" placeholder="请输入金额" />
<script>
$(function(){
$('#cashMoney').bind('input propertychange',amountVal );
});
function amountVal(){
var replyGold=document.getElementById("cashMoney");
var regStrs = [
['[^\\d\\.]+$', ''], //禁止录入任何非数字和点
['\\.(\\d?)\\.+', '.$1'], //禁止录入两个以上的点
['^(\\d+\\.\\d{2}).+', '$1'] //禁止录入小数点后两位以上
];
for(i=0; i<regStrs.length; i++){
var reg = new RegExp(regStrs[i][0]);
replyGold.value = replyGold.value.replace(reg, regStrs[i][1]);
}
}
</script>