金钱大小写转换
function money_uppercase(value) {
re = /^-?[0-9]*(\.[0-9]{0,2})?$/i;
if( !re.exec(value))
{
alert('请正确输入金额(允许两位小数)!');
return false;
}
return piliskysMoney(value);
}
function piliskys(val){
if(isNaN(val)) {
return creat(0);
}
else return creat(val);
}
function creat(val){
var money1 = new Number(val);
if(money1> 1000000000000000000) {
alert("你输入的数字太大,重新输入!");
return;
}
var monee = Math.round(money1*100).toString(10)
var i,j;
j=0;
var leng = monee.length;
var monval="";
for( i=0;i<leng;i++)
{
monval= monval+to_upper(monee.charAt(i))+to_mon(leng-i-1);
}
return repace_acc(monval);
}
function to_upper( a)
{
switch(a){
//case '-' : return '负'; break;
case '0' : return '零'; break;
case '1' : return '壹'; break;
case '2' : return '贰'; break;
case '3' : return '叁'; break;
case '4' : return '肆'; break;
case '5' : return '伍'; break;
case '6' : return '陆'; break;
case '7' : return '柒'; break;
case '8' : return '捌'; break;
case '9' : return '玖'; break;
default: return '' ;
}
}
function to_mon(a){
if(a>10){ a=a - 8;
return(to_mon(a));}
switch(a){
case 0 : return '份'; break;
case 1 : return ''; break;
case 2 : return '点'; break;
case 3 : return '拾'; break;
case 4 : return '佰'; break;
case 5 : return '仟'; break;
case 6 : return '万'; break;
case 7 : return '拾'; break;
case 8 : return '佰'; break;
case 9 : return '仟'; break;
case 10 : return '亿'; break;
}
}
function repace_acc(Money){
Money=Money.replace("零份","");
Money=Money.replace("零份","零");
var yy;
var outmoney;
outmoney=Money;
yy=0;
while(true){
var lett= outmoney.length;
outmoney= outmoney.replace("零点","点");
outmoney= outmoney.replace("零万","万");
outmoney= outmoney.replace("零亿","亿");
outmoney= outmoney.replace("零仟","零");
outmoney= outmoney.replace("零佰","零");
outmoney= outmoney.replace("零零","零");
outmoney= outmoney.replace("零拾","零");
outmoney= outmoney.replace("亿万","亿零");
outmoney= outmoney.replace("万仟","万零");
outmoney= outmoney.replace("仟佰","仟零");
yy= outmoney.length;
if(yy==lett) break;
}
yy = outmoney.length;
if ( outmoney.charAt(yy-1)=='零'){
outmoney=outmoney.substring(0,yy-1);
}
yy = outmoney.length;
if ( outmoney.charAt(yy-1)=='份'){
outmoney=outmoney +'';
}
return outmoney;
//document.getElementById('da').innerHTML=outmoney;
//alert(outmoney);
}
function vol_uppercase(value_num)
{
value = ''+value_num;
re = /^-?[0-9]*(\.[0-9]{0,2})?$/i;
if( !re.exec(value))
{
alert('请正确输入份额(允许两位小数)!');
return false;
}
p='';
var val=p+piliskys(value);
if(val.substring(val.length-1,val.length)=='点'){
val=val.substr(0,val.length-1)+'份整';
}
if(val.substring(val.length-1,val.length-2)=='点'){
val=val+'份';
}
if(value.substring(0,2)=='0.'){
val="零点"+val;
if(val.substring(val.length-1,val.length-2)=='点'){
val=val+'份';
}
}
return val;
}
function piliskysMoney(val){
if(isNaN(val)) {
return creatMoney(0);
}
else return creatMoney(val);
}
function creatMoney(val){
var money1 = new Number(val);
if(money1> 1000000000000000000) {
alert("你输入的数字太大,重新输入!");
return;
}
var monee = Math.round(money1*100).toString(10)
var i,j;
j=0;
var leng = monee.length;
var monval="";
for( i=0;i<leng;i++)
{
monval= monval+to_upperMoney(monee.charAt(i))+to_monMoney(leng-i-1);
}
return repace_accMoney(monval);
}
function to_upperMoney( a)
{
switch(a){
//case '-' : return '负'; break;
case '0' : return '零'; break;
case '1' : return '壹'; break;
case '2' : return '贰'; break;
case '3' : return '叁'; break;
case '4' : return '肆'; break;
case '5' : return '伍'; break;
case '6' : return '陆'; break;
case '7' : return '柒'; break;
case '8' : return '捌'; break;
case '9' : return '玖'; break;
default: return '' ;
}
}
function to_monMoney(a){
if(a>10){ a=a - 8;
return(to_mon(a));}
switch(a){
case 0 : return '分'; break;
case 1 : return '角'; break;
case 2 : return '元'; break;
case 3 : return '拾'; break;
case 4 : return '佰'; break;
case 5 : return '仟'; break;
case 6 : return '万'; break;
case 7 : return '拾'; break;
case 8 : return '佰'; break;
case 9 : return '仟'; break;
case 10 : return '亿'; break;
}
}
function repace_accMoney(Money){
Money=Money.replace("零分","");
Money=Money.replace("零角","零");
var yy;
var outmoney;
outmoney=Money;
yy=0;
while(true){
var lett= outmoney.length;
outmoney= outmoney.replace("零元","元");
outmoney= outmoney.replace("零万","万");
outmoney= outmoney.replace("零亿","亿");
outmoney= outmoney.replace("零仟","零");
outmoney= outmoney.replace("零佰","零");
outmoney= outmoney.replace("零零","零");
outmoney= outmoney.replace("零拾","零");
outmoney= outmoney.replace("亿万","亿零");
outmoney= outmoney.replace("万仟","万零");
outmoney= outmoney.replace("仟佰","仟零");
yy= outmoney.length;
if(yy==lett) break;
}
yy = outmoney.length;
if ( outmoney.charAt(yy-1)=='零'){
outmoney=outmoney.substring(0,yy-1);
}
yy = outmoney.length;
if ( outmoney.charAt(yy-1)=='元'){
outmoney=outmoney +'整';
}
return outmoney;
}
function tausendstel(value){
re = /(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
var n = value.replace(re,"?,");
document.getElementById("tradeAmount").value = n;
}
function tausendstel_redeemfund(value){
re = /(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
var n = value.replace(re,"?,");
document.getElementById("redeemVol").value = n;
}
function tausendstel_transfer(value){
re = /(\d{1,3})(?=(\d{3})+(?:$|\.))/g;
var n = value.replace(re,"?,");
document.getElementById("transferVol").value = n;
}
function commafyback(value)
{
if (isEmpty(value)) {
return;
}
var x = value.split(',');
return parseFloat(x.join(""));
}
?
money_uppercase(value);