<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<title>金額轉大寫</title>
#</head>
<body>
#<div>
<h2>金額轉大寫</h2>
<lable for="amount">請輸入金額:¥</lable>
< input id="amount" type="text" />
<p></p>
<button onclick="change()">點選轉換< ;/button>
<p id="demo"></p>
</div>
<腳本類型=“text/javascript”>
functionchange(){
varmoney=document.getElementById("amount").value;
document.getElementById("demo").innerHTML=toCapitalization(money);
}
function toCapitalization(money){
var Capitalization= "";
var unitInt="整";
if(isAmount(money)){
if(money==parseInt(money)){
var l=getlength(money);
if(l>=10){
capitalization="您輸入的金額過大!";
##} else{capitalization=getCap(money,l,0,l) unitInt;#}}else{var mPstr=money "" ;var m=mPstr.split("."); var mPInt=m[0];
# 1# var len=mPPoint.length;
var numI=parseInt(mPInt);
var numP=parse(mPget); 寫th(numI) ,0,len)
getCap(numP,getlength(numP),1,len);
}
}else{
capitalization="請輸入正確的金額!";
}
返回大小寫;
#}
function getlength(num){
var str=num "";
return str.length;
}
function isAmount(num){
##var ret=/ ^(( [1-9][0-9]*)|((([0])|([1-9][0-9]*))\.(([1-9])|( [0- 9][1-9])))|([0]))$/;if(ret.test(num)){return true;}else{return false;}}function gerArray(num,l,k,len){var nums=[];if(k==1 && l!=len){nums[0]=0;nums[ 1]= num;}else{for(i=1;i<=l;i ){nums[l-i]=num ; if(l-i>0){num=(num-nums[l-i])/10;}##}
}
#return nums;
}
function getUnit(i,k){
//k=0 表示整數部分k=1表示小數部分
var unit=["圓","拾","佰","仟","萬","拾","佰","仟","億"];
# var unitPoint=["角","分"];
if(i<9 && k==0){
return unit[i];
} else if(i<2 && k==1){
return unitPoint[i];
}
#}
function getNumber(i) {
var 大寫=["零","壹","贒","叁","肆","","陸","伍柒","捌","玖" ];
傳回大小寫[i];
}
function getCap(num,l,k,len){
var nums=gerArray (num,l,k,len);
var str='';
if(k==0){
for(i =0;i< l;i){
str=str getNumber(nums[i]) getUnit(l-i-1,k);
}
}else{
##for(i=0; i