<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<tajuk>Jumlah yang ditukar kepada huruf besar&
. ¥< ;/lable><input id="amount" type="text" /><p></p><butang onclick="change()">Klik untuk menukar< ;/button><p id="demo"></p></div><script type="text/javascript">
function change(){
var money=document.getElementById("amount").value;
document.getElementById("demo").innerHTML =toCapitalization(money);
}
function toCapitalization(money){
var capitalization="";
var unitInt="整";
if(isAmount(money)){
(=parseInt(money)){
var l=getlength(money);
if(l>=10){
capitalization="您输入的金额过大!";
talization= getCap(money,l,0,l)+unitInt;}}else{var mPstr=money+""; var m=mPstr.split("."); var mPstr [0]; var mPPoint=m[1]; var len=mPPoint.length; var numI=parse );numP=parseInt(mPPoint);
capitalization=getCap(numI ,getlength(numI),0,len)
+getCap(numP,getlength(numP),1,len);
}
}else{
capitalization="请输入!死"箢! }
kembali huruf besar;
}
fungsi getlength(bilangan){
var str=num+"";
return str.length;
}
)fungsi ialahJumlah/
^(([1-9][0-9]*)|((([0])|([1-9][0-9]*)).(([1-9])|([ 0-9][1-9])))|([0]))$/;jika(kembali.test(bilangan)){kembali benar;}lain{kembali palsu;}}fungsi gerArray(num,l,k,len){var nums=[];if(k==1 && l!=len){nums[0]=0 ;nums[1]=num;}lain{for(i=1;i<=l;i++){nums[l-i]=num%10;if(l-i> 0){num=(num-nums[l-i])/10;}}}kembali nombor;}fungsi getUnit(i,k)
=0 表示整数部分 k=1表示小数部分
var unit=["圆","拾","佰","仟","万","拾","佰","仟","亿"];
var unitPoint=["角","分"];
if(i<9 && k==0){
unit pulangkan[i];
; (i<9 && k==0){
unit pulangkan[i];
; (i&}else && k==1){
kembali unitPoint[i];
}
}
fungsi getNumber(i){
var capitalization=["零",""壹","聽,"肆","伍","陆","柒","捌","玖"];
kembali huruf besar[i];
}
fungsi 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);
}
}lain{
for(i=0;i<len;i++){
str=str +getNumber(nums[i])+getUnit(i,k);
}
}
return str;
}
</script>
</body>
>;