js 金额小写转换为大写

<script>
     jQuery(document).ready(function () {
         //当金额文本框失去焦点时,自动将数字转化为大写填充到 大写的文本框中
         $("#Amount").blur(function () {
             var amount = $("#Amount").val();
             amount = AmountLtoU(amount);
             $("#CapitalAmount").val(amount);
         });
     });

     function AmountLtoU(num) {
         ///<summery>小写金额转化大写金额</summery>
         ///<param name=num type=number>金额</param>
         if (isNaN(num)) return "";
         var strPrefix = "";
         if (num < 0) strPrefix = "(负)";
         num = Math.abs(num);
         if (num >= 1000000000000) return "无效数值!";
         var strOutput = "";
         var strUnit = ‘仟佰拾亿仟佰拾万仟佰拾元角分‘;
         var strCapDgt = ‘零壹贰叁肆伍陆柒捌玖‘;
         num += "00";
         var intPos = num.indexOf(‘.‘);
         if (intPos >= 0) {
             num = num.substring(0, intPos) + num.substr(intPos + 1, 2);
         }
         strUnit = strUnit.substr(strUnit.length - num.length);
         for (var i = 0; i < num.length; i++) {
             strOutput += strCapDgt.substr(num.substr(i, 1), 1) + strUnit.substr(i, 1);
         }
         return strPrefix + strOutput.replace(/零角零分$/, ‘整‘).replace(/零[仟佰拾]/g, ‘零‘).replace(/零{2,}/g, ‘零‘).replace(/零([亿|万])/g, ‘$1‘).replace(/零+元/, ‘元‘).replace(/亿零{0,3}万/, ‘亿‘).replace(/^元/, "零元");
     };
    </script>
时间: 2024-11-05 16:07:55

js 金额小写转换为大写的相关文章

C#金额小写转换为大写

//传入需要转换的金额(字符串) public static string MoneyToChinese(string strAmount)     { string functionReturnValue = null; bool IsNegative = false; // 是否是负数 if (strAmount.Trim().Substring(0, 1) == "-")         { // 是负数则先转为正数 strAmount = strAmount.Trim().Re

JS函数实现金额小写转大写

止乎于分享! 1 ///<summery>小写金额转化大写金额</summery> 2 function AmountLtoU(amount) { 3 if (isNaN(amount) || amount >= 1000000000000) return "无效金额!"; //数值最大不超过1万亿 4 var sPrefix = amount < 0 ? "(负)" : ""; //将负号‘-’显示成汉字‘(

将金额数字转换为大写汉字的js函数

1 //将金额数字转换为大写汉字的函数 2 function convertCurrency(money) { 3 //汉字的数字 4 var cnNums = new Array('零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖'); 5 //基本单位 6 var cnIntRadice = new Array('', '拾', '佰', '仟'); 7 //对应整数部分扩展单位 8 var cnIntUnits = new Array('', '

传入一个字符串,已知字符串只由字母组成,将其中的大写字母转换为小写,小写转换为大写,返回转换后的字符串

传入一个字符串,已知字符串只由字母组成,将其中的大写字母转换为小写,小写转换为大写,返回转换后的字符串 如传入:@"GOODgoodSTUDY",返回@"goodGOODstudy" */ - (NSString *)upperExchangeLower:(NSString *)str { NSMutableString *str1=[[NSMutableString alloc] initWithString:str]; for (NSUInteger i=0;

[转] 金额小写变大写

1 /// <summary> 2 /// 金额小写变大写 3 /// </summary> 4 /// <param name="smallnum"></param> 5 /// <returns></returns> 6 public static string gMoney(decimal smallnum) 7 { 8 string cmoney , cnumber, cnum, cnum_end,cmon

C#金额小写转大写

public string ConvertMoney(decimal Money) { //金额转换程序 string MoneyNum = "";//记录小写金额字符串[输入参数] string MoneyStr = "";//记录大写金额字符串[输出参数] string BNumStr = "零壹贰叁肆伍陆柒捌玖";//模 string UnitStr = "万仟佰拾亿仟佰拾万仟佰拾圆角分";//模 MoneyNum =

SQL金额小写转大写

CREATE FUNCTION dbo.L2U(@n_LowerMoney numeric(15,2),@v_TransType int) RETURNS VARCHAR(200) AS BEGIN Declare @v_LowerStr VARCHAR(200) -- 小写金额 Declare @v_UpperPart VARCHAR(200) Declare @v_UpperStr VARCHAR(200) -- 大写金额 Declare @i_I int set @v_LowerStr =

js实现小写转大写,js实现数字转人民币

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>小写转大写</title> <style type="text/css"> div { position:absolute;left:lin;top:lin;bottom:lin;right:lin; background-col

JS将货币小写转换为大写

/** 数字金额大写转换(可以处理整数,小数,负数) */ function smalltoBIG(n) { var fraction = ['角', '分']; var digit = ['零', '壹', '贰', '叁', '肆', '伍', '陆', '柒', '捌', '玖']; var unit = [ ['元', '万', '亿'], ['', '拾', '佰', '仟'] ]; var head = n < 0? '欠': ''; n = Math.abs(n); var s =