zoukankan      html  css  js  c++  java
  • 金额大小写转换

    function ToTrans(a) {
        var b = 9.999999999999E10,
        f = "\u96f6",
        h = "\u58f9",
        g = "\u8d30",
        e = "\u53c1",
        k = "\u8086",
        p = "\u4f0d",
        q = "\u9646",
        r = "\u67d2",
        s = "\u634c",
        t = "\u7396",
        l = "\u62fe",
        d = "\u4f70",
        i = "\u4edf",
        m = "\u4e07",
        j = "\u4ebf",
        u = "人民币",
        o = "\u5143",
        c = "\u89d2",
        n = "\u5206",
        v = "\u6574";
        a = a.toString();
        if (a == "") {
        	Dialog.alert("转换内容不能为空!");
            return ""
        }
        if (a.match(/[^,.\d]/) != null) {
        	Dialog.alert("输入有误,请输入小数点和纯数字!");
            return ""
        }
        if (a.match(/^((\d{1,3}(,\d{3})*(.((\d{3},)*\d{1,3}))?)|(\d+(.\d+)?))$/) == null) {
        	Dialog.alert("输入有误,请输入小数点和纯数字!");
            return ""
        }
        a = a.replace(/,/g, "");
        a = a.replace(/^0+/, "");
        if (Number(a) > b) {
        	Dialog.alert("\u5bf9\u4e0d\u8d77,\u4f60\u8f93\u5165\u7684\u6570\u5b57\u592a\u5927\u4e86!\u6700\u5927\u6570\u5b57\u4e3a99999999999.99\uff01");
            return ""
        }
        b = a.split(".");
        if (b.length > 1) {
            a = b[0];
            b = b[1];
            b = b.substr(0, 2)
        } else {
            a = b[0];
            b = ""
        }
        h = new Array(f, h, g, e, k, p, q, r, s, t);
        l = new Array("", l, d, i);
        m = new Array("", m, j);
        n = new Array(c, n);
        c = "";
        if (Number(a) > 0) {
            for (d = j = 0; d < a.length; d++) {
                e = a.length - d - 1;
                i = a.substr(d, 1);
                g = e / 4;
                e = e % 4;
                if (i == "0") j++;
                else {
                    if (j > 0) c += h[0];
                    j = 0;
                    c += h[Number(i)] + l[e]
                }
                if (e == 0 && j < 4) c += m[g]
            }
            c += o
        }
        if (b != "") for (d = 0; d < b.length; d++) {
            i = b.substr(d, 1);
            if (i != "0") c += h[Number(i)] + n[d]
        }
        if (c == "") c = f + o;
        if (b.length < 2) c += v;
        return c;
    }
    
  • 相关阅读:
    SSRS中加入书签功能及数据集窗口
    Oracle 语法
    DOM基本操作
    文字横向滚动和垂直向上滚动
    offsetWidth和width的区别
    css3动画(animation)效果3-正方体合成
    css3动画(animation)效果2-旋转的星球
    css3动画(animation)效果1-漂浮的白云
    JavaScript 错误监控Fundebug
    第二篇:git创建流程
  • 原文地址:https://www.cnblogs.com/evilrogue/p/3049323.html
Copyright © 2011-2022 走看看