<html>
<head>
<title>数字转换人民币大写</title>
<script type="text/javascript">
function convert() {
var big = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖");
var unit = new Array("圆", "拾", "佰", "仟", "万", "拾", "佰", "仟", "亿", "拾",
"佰", "仟", "万");
var num = document.getElementById("num").value;
if (num =="") {
alert("输入为空,请输入数字");
return false;
}
if (num.match(/[^,.\d]/) != null) {
alert("输入内容不合法,请输入数字");
return false;
}
var temp = "";
if (num != null&&num.length<=13) {
for (var i = 0; i < num.length; i++) {
if(num.charAt(i)==0){
alert("输入内容不合法,不能以0开始");
return false;
}else{
temp = temp + big[num.charAt(i)] + unit[num.length - i - 1];
}
}
}else{
alert("最多只能输入13位数字");
return false;
}
document.getElementById("rmb").innerText = temp;
}
</script>
</head>
<body>
<input type="text" name="num" id="num"/>
<input type="button" name="convert" value="转换" onclick="return convert()"/>
<input type="text" id="rmb"/>
</body>
</html>