金額小寫自動轉為大寫

2021-07-29 15:03:54 字數 2284 閱讀 3390

輸入數字:

大寫金額:

var maximum_number = 999999999999.99;  //最大值

// 定義轉移字元

var cn_zero = "零";

var cn_one = "壹";

var cn_two = "貳";

var cn_three = "叄";

var cn_four = "肆";

var cn_five = "伍";

var cn_six = "陸";

var cn_seven = "柒";

var cn_eight = "捌";

var cn_nine = "玖";

var cn_ten = "拾";

var cn_hundred = "佰";

var cn_thousand = "仟";

var cn_ten_thousand = "萬";

var cn_hundred_million = "億";

var cn_dollar = "元";

var cn_ten_cent = "角";

var cn_cent = "分";

var cn_integer = "整";

// 初始化驗證:

var integral, decimal, outputcharacters, parts;

var digits, radices, bigradices, decimals;

var zerocount;

var i, p, d;

var quotient, modulus;

// 驗證輸入字串是否合法

/*if (currencydigits.tostring() == "") */

/*if (!currencydigits.match(/[^,.\d]/)) */

//判斷是否輸入有效的數字格式

/* var reg = /^((\d(,\d)*(.((\d,)*\d))?)|(\d+(.\d+)?))$/;

if (!reg.test(currencydigits)) */

currencydigits = currencydigits.replace(/,/g, "");

currencydigits = currencydigits.replace(/^0+/, "");

//判斷輸入的數字是否大於定義的數值

if (number(currencydigits) > maximum_number)

parts = currencydigits.split(".");

if (parts.length > 1)

else

// 例項化字元大寫人民幣漢字對應的數字

digits = new array(cn_zero, cn_one, cn_two, cn_three, cn_four, cn_five, cn_six, cn_seven, cn_eight, cn_nine);

radices = new array("", cn_ten, cn_hundred, cn_thousand);

bigradices = new array("", cn_ten_thousand, cn_hundred_million);

decimals = new array(cn_ten_cent, cn_cent);

outputcharacters = "";

//大於零處理邏輯

if (number(integral) > 0)

else

zerocount = 0;

outputcharacters += digits[number(d)] + radices[modulus];

}if (modulus == 0 && zerocount < 4)

}outputcharacters += cn_dollar;

}// 包含小數部分處理邏輯

if (decimal != "") }}

//確認並返回最終的輸出字串

if (outputcharacters == "")

if (decimal == "")

//獲取人民幣大寫

$("#getcapital").val(outputcharacters);

}

記住要更新jquery路徑!最多支援到千億級別。效果如下:

數字金額轉為大寫金額

金額轉大寫 public class moneyconvertchinese string strlower null string strupart null string strupper null int itemp 0 保留兩位小數 123.489 123.49 123.4 123.4 lo...

數字金額轉為大寫金額 C

數字金額轉為大寫金額 c 複製 ie有效 列印關於 金額轉大寫 public class moneyconvertchinese string strlower null string strupart null string strupper null intitemp 0 保留兩位小數 123....

金額小寫轉大寫

create procedure dbo trannumbertobigfordecrypt n lowermoney numeric 15,2 v transtype int,ret varchar 200 output with encryption as descript 解密exec sp ...