jquery Amount converted to uppercase

Source: Internet
Author: User

<script language= "javascript" type= "Text/javascript" >
function Arabia_to_chinese (Num) {
for (i = num.length-1; I >= 0; i--) {
Num = Num.replace (",", "")//Replace "," in Tomoney ()
Num = Num.replace ("", "")//Replace space in Tomoney ()
}
Num = Num.replace ("¥", "")//Replace the ¥ character that may appear
if (IsNaN (Num)) {//Verify the character entered is a number
Alert ("Please check if the lowercase amount is correct");
Return
}
---character processing is complete, the conversion is started, and the conversion is converted by two parts---//
Part = String (Num). Split (".");
Newchar = "";
Convert before the decimal point
for (i = part[0].length-1; I >= 0; i--) {
if (Part[0].length >) {alert ("The number of digits is too large to calculate"); return "";} If the quantity exceeds the million units, the prompt
Tmpnewchar = ""
Perchar = Part[0].charat (i);
Switch (Perchar) {
Case "0": Tmpnewchar = "0" + Tmpnewchar; Break
Case "1": Tmpnewchar = "one" + Tmpnewchar; Break
Case "2": Tmpnewchar = "II" + Tmpnewchar; Break
Case "3": Tmpnewchar = "three" + Tmpnewchar; Break
Case "4": Tmpnewchar = "Restaurant" + Tmpnewchar; Break
Case "5": Tmpnewchar = "WU" + tmpnewchar; Break
Case "6": Tmpnewchar = "Lu" + tmpnewchar; Break
Case "7": Tmpnewchar = "Qi" + Tmpnewchar; Break
Case "8": Tmpnewchar = "ba" + Tmpnewchar; Break
Case "9": Tmpnewchar = "JIU" + Tmpnewchar; Break
}
Switch (part[0].length-i-1) {
Case 0:tmpnewchar = Tmpnewchar + "Yuan"; Break
Case 1:if (Perchar! = 0) Tmpnewchar = Tmpnewchar + "Pick up";
Case 2:if (Perchar! = 0) Tmpnewchar = Tmpnewchar + "Bai";
Case 3:if (Perchar! = 0) Tmpnewchar = Tmpnewchar + "thousand";
Case 4:tmpnewchar = Tmpnewchar + "million"; Break
Case 5:if (Perchar! = 0) Tmpnewchar = Tmpnewchar + "Pick up";
Case 6:if (Perchar! = 0) Tmpnewchar = Tmpnewchar + "Bai";
Case 7:if (Perchar! = 0) Tmpnewchar = Tmpnewchar + "thousand";
Case 8:tmpnewchar = Tmpnewchar + "billion"; Break
Case 9:tmpnewchar = Tmpnewchar + "pickup"; Break
}
Newchar = Tmpnewchar + Newchar;
}
Convert after a decimal point
if (Num.indexof (".")! =-1) {
if (Part[1].length > 2) {
Alert ("Only two digits can be left after the decimal point, the system will automatically intercept segments");
PART[1] = part[1].substr (0, 2)
}
for (i = 0; i < part[1].length; i++) {
Tmpnewchar = ""
Perchar = Part[1].charat (i)
Switch (Perchar) {
Case "0": Tmpnewchar = "0" + Tmpnewchar; Break
Case "1": Tmpnewchar = "one" + Tmpnewchar; Break
Case "2": Tmpnewchar = "II" + Tmpnewchar; Break
Case "3": Tmpnewchar = "three" + Tmpnewchar; Break
Case "4": Tmpnewchar = "Restaurant" + Tmpnewchar; Break
Case "5": Tmpnewchar = "WU" + tmpnewchar; Break
Case "6": Tmpnewchar = "Lu" + tmpnewchar; Break
Case "7": Tmpnewchar = "Qi" + Tmpnewchar; Break
Case "8": Tmpnewchar = "ba" + Tmpnewchar; Break
Case "9": Tmpnewchar = "JIU" + Tmpnewchar; Break
}
if (i = = 0) Tmpnewchar = Tmpnewchar + "angle";
if (i = = 1) Tmpnewchar = Tmpnewchar + "min";
Newchar = Newchar + Tmpnewchar;
}
}
Replace all useless characters
while (Newchar.search ("00")! =-1)
Newchar = Newchar.replace ("00", "0");
Newchar = Newchar.replace ("0", "billion");
Newchar = Newchar.replace ("Billions", "billion");
Newchar = Newchar.replace ("0", "million");
Newchar = Newchar.replace ("0 yuan", "Yuan");
Newchar = Newchar.replace ("0 angle", "" ");
Newchar = Newchar.replace ("0 points", "");

if (Newchar.charat (newchar.length-1) = = "Yuan" | | Newchar.charat (newchar.length-1) = = "Angle")
Newchar = Newchar + "whole"
document.write (Newchar);
return Newchar;

}
</script>

Reference: http://17jquery.com/javascript/27846/

jquery Amount converted to uppercase

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.