限制只能输入小数点后两位
<script type="text/javascript">
function strNumber(elm){
elm.value = elm.value.replace(/^[^0-9.]*(\d*[\.]?\d{0,2})\w*$/,'$1');
}
</script>
<input type="text" onkeyup="strNumber(this)"/>
但行好事,莫问前程。
<script type="text/javascript">
function strNumber(elm){
elm.value = elm.value.replace(/^[^0-9.]*(\d*[\.]?\d{0,2})\w*$/,'$1');
}
</script>
<input type="text" onkeyup="strNumber(this)"/>