在一個輸入框中,如何在onblur事件發生前(焦點離開前),不管輸入數字有多少位小數,但Value值為四舍五入後小數點保留兩位?
---------------------------------------------------------------
1<input name="textfield" onblur="javascript:this.value=parseFloat(this.value).toFixed(2)" onkeyup="this.value=this.value.replace(/[^0-9.]/,'');" type="text"/>
---------------------------------------------------------------
1<input name="textfield" onblur="javascript:this.value=Math.round(parseFloat(this.value)*100)/100" onkeyup="this.value=this.value.replace(/[^0-9.]/,'');" type="text"/>