日期:2014-05-16 浏览次数:20363 次
<input type="text" id="text" />
<script type="text/javascript">
document.getElementById("text").onkeyup=function(){
if(!/^\d*\.?\d{0,2}$/.test(this.value))
this.value = this.value.replace(/[^\d\.]/g,"").replace(/^(\d*\.?\d{0,2}).*/g,"$1");
}
</script>