[QUOTE]<form name="form1">
数量:<input type="text" name="aa_1" onpropertychange="bb()" onkeyup="this.value=this.value.replace(/[^\d\.]/g,'')"><br>
单价:<input type="text" name="aa_2" onpropertychange="bb()" onkeyup="this.value=this.value.replace(/[^\d\.]/g,'')"><br>
总价:<input type="text" name="aa_3"><br>
付款:<input type="text" name="aa_4" onpropertychange="bb()" onkeyup="this.value=this.value.replace(/[^\d\.]/g,'')"><br>
找零:<input type="text" name="aa_5"><br>
</form>
<script language="javascript">
function bb(){
if(document.form1.aa_1.value!="" && document.form1.aa_2.value!=""){
document.form1.aa_3.value=(document.form1.aa_1.value*document.form1.aa_2.value).toFixed(2);
if(document.form1.aa_4.value!=""){
document.form1.aa_5.value=document.form1.aa_4.value-document.form1.aa_3.value;
}
}
}
</script>[/QUOTE]
我只会一点正则表达式
onkeyup="this.value=this.value.replace(/[^\d\.]/g,'')"这个正则表达式可以改一下,只让用户输入一个小数点