手机版

将人民币数字位钱数转化为中文钱数的射流研究…函数

时间:2021-11-24 来源:互联网 编辑:宝哥软件园 浏览:

效果图:

效果演示:[Ctrl A全选注:如需引入外部射流研究…需刷新才能执行]核心代码:复制代码代码如下:函数changermtoch(Num){ for(I=Num。长度-1;I=0;i - ) { Num=Num.replace(',',' ')//替换tomoney()中的“,”Num=Num.replace(“”、“”)//替换tomoney()中的空格} Num=Num。替换(' | ',' ')//替换掉可能出现的字符if(isNaN(Num)) { //验证输入的字符是否为数字警报('请检查小写金额是否正确');返回"";} //- 字符处理完毕,开始转换,转换采用前后两部分分别转换- //部分=字符串(数字).拆分('.');newchar=//小数点前进行转化for(i=part[0]).长度-1;I=0;i - ) { if(part[0]).长度10){ alert('位数过大,无法计算');返回"";}//若数量超过拾亿单位,提示tmpnewchar=' purper=part[0].charAt(I);switch(pencer){ case ' 0 ' : tmpnewchar='零tmpnewchar打破;案例1': tmpnewchar='壹tmpnewchar打破;案例2': tmpnewchar='贰tmpnewchar打破;案例3': tmpnewchar='叁tmpnewchar打破;案例4': tmpnewchar='肆tmpnewchar打破;案例5': tmpnewchar='伍tmpnewchar打破;案例6': tmpnewchar='陆tmpnewchar打破;案例7': tmpnewchar='柒tmpnewchar打破;案例8': tmpnewchar='捌tmpnewchar打破;案例9': tmpnewchar='玖tmpnewchar打破;}开关(零件[0]。length-I-1){ case 0: tmpnewchar=tmpnewchar '元;打破;案例1: if(penter!=0)tmpnewchar=tmpnewchar '拾;打破;案例2: if(penter!=0)tmpnewchar=tmpnewchar '佰;打破;案例3: if(penter!=0)tmpnewchar=tmpnewchar '仟;打破;案例4: tmpnewchar=tmpnewchar '万;打破;案例5: if(penter!=0)tmpnewchar=tmpnewchar '拾;打破;案例6: if(penter!=0)tmpnewchar=tmpnewchar '佰;打破;案例7: if(penter!=0)tmpnewchar=tmpnewchar '仟;打破;case 8: tmpnewchar=tmpnewchar '亿;打破;case 9: tmpnewchar=tmpnewchar '拾;打破;} newchar=tmpnewchar newchar} //小数点之后进行转化if(Num.indexOf(')。')!=-1) { if(part[1]).长度2) { alert('小数点之后只能保留两位,系统将自动截段');第[1]部分.substr(0,2)} for(I=0;ipart[1].长度;I){ tmpnewchar=' purper=part[1].charAt(i)开关(胶芯){ case '0': tmpnewchar='零tmpnewchar打破;案例1': tmpnewchar='壹tmpnewchar打破;案例2': tmpnewchar='贰tmpnewchar打破;案例3': tmpnewchar='叁tmpnewchar打破;案例4': tmpnewchar='肆tmpnewchar打破;案例5': tmpnewchar='伍tmpnewchar打破;案例6': tmpnewchar='陆tmpnewchar打破;案例7': tmpnewchar='柒tmpnewchar打破;案例8': tmpnewchar='捌tmpnewchar打破;案例9': tmpnewchar='玖tmpnewchar打破;} if(i==0)tmpnewchar=tmpnewchar '角;if(i==1)tmpnewchar=tmpnewchar '分;new char=new char tmpnewchar } } if(new char . search('分') !=-1) { newchar=newchar.replace('零角', '零');} //替换所有无用汉字while(newchar.search('零零') !=-1) newchar=newchar.replace('零零', '零');newchar=newchar.replace('零亿', '亿');newchar=newchar.replace('亿万', '亿');newchar=newchar.replace('零万', '万');newchar=newchar.replace('零元', '元');newchar=newchar.replace('零角', '');newchar=newchar.replace('零分', '');if(新字符。charat(新字符。长度-1)='元| |新字符。charat(新字符。长度-1)='角)newchar=newchar '整;返回newchar}

版权声明:将人民币数字位钱数转化为中文钱数的射流研究…函数是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。