附: 代碼如下: /* * formatMoney(s,type) * 功能:金額按千位逗號(hào)分割 * 參數(shù):s,需要格式化的金額數(shù)值. * 參數(shù):type,判斷格式化后的金額是否需要小數(shù)位. * 返回:返回格式化后的數(shù)值字符串. */ function formatMoney(s, type) { if (/[^0-9\.]/.test(s)) return "0"; if (s == null || s == "") return "0"; s = s.toString().replace(/^(\d*)$/, "$1."); s = (s + "00").replace(/(\d*\.\d\d)\d*/, "$1"); s = s.replace(".", ","); var re = /(\d)(\d{3},)/; while (re.test(s)) s = s.replace(re, "$1,$2"); s = s.replace(/,(\d\d)$/, ".$1"); if (type == 0) {// 不帶小數(shù)位(默認(rèn)是有小數(shù)位) var a = s.split("."); if (a[1] == "00") { s = a[0]; } } return s; } /* * 通用DateAdd(interval,number,date) 功能:實(shí)現(xiàn)javascript的日期相加功能. * 參數(shù):interval,字符串表達(dá)式,表示要添加的時(shí)間間隔. 參數(shù):number,數(shù)值表達(dá)式,表示要添加的時(shí)間間隔的個(gè)數(shù). 參數(shù):date,時(shí)間對(duì)象. * 返回:新的時(shí)間對(duì)象. var now = new Date(); var newDate = DateAdd("day",5,now); * author:devinhua(從○開始) update:2010-5-5 20:35 */ function DateAdd(interval, number, date) { if (date == null) return ""; switch (interval) { case "day": date = new Date(date); date = date.valueOf(); date += number * 24 * 60 * 60 * 1000; date = new Date(date); return date; break; default: return ""; break; } }