首页 > 代码库 > 人民币 小写金额转换为大写金额

人民币 小写金额转换为大写金额

### 人民币 小写金额转换为大写金额

标签(空格分隔): 人民币 小写金额转换为大写金额

---

jsp:
```
div class="form-group">
<label class="col-sm-4 control-label">
合计人民币金额(小写):
</label>
<div class="col-sm-7">
<input id="totalRmbLower" type="text" name="entity.totalRmbLower" value="http://www.mamicode.com/${entity.totalRmbLower}" placeholder="" class="form-control">
</div>
</div>
```

js:将输入的小写金额 转换成大写金额
```
function arabiaToChinese(num) {
if (isNaN(num)) return "";
var strPrefix = "";
if (num <
0) strPrefix = "(负)";
num = M ath.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 += s trCapDgt.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(/^元/, "零元");
}
```

js:
```
$("#totalRmbLower").focus(function() {
var totalRmbLower = 0;
for (var i = 0; i < cList.length; i++) {
totalRmbLower = cList[i].amount + totalRmbLower;
}
$("input[name=‘entity.totalRmbLower‘]").val(totalRmbLower);
});
```

 

人民币 小写金额转换为大写金额