/ ************************************************** *****
FILENAME: JSLibrary.js
Company Technology Development Department, 2003-xxxx ********
Writer: Nick
Create Date: 2004-12-28
Rewriter:
Rewrite Date:
Impact:
*********************************************************** **** /
/ * ================================================================================================================================================================ ================== Public function: Function: Check if you want to display a prompt window ===================== ====================================================== * / function ifshow Showmsg) {IF (showmsg == ") {Return False;} else {return true;}}
/ * ================================================================================================================================================================ ================== Features: Replace space (replace multiple consecutive spaces with a space): ReplaceSpace (obj) Returns: string ======== ============================================================================================================================================================================================================= ======== * / function replaceSpace (STR) {while (str .indexof ("")> = 0) {str = str.replace ("," ");} Return Str;} / * ============================================================================================================================================================================================================= ================ Function: Non-empty inspection, do not ignore space reminder information: The input box is empty, please enter! Use: isnull (OBJ, String) Returns: BOOL ======================================= =====================================================================================================================================3
// Non-empty inspection if (obj.value == ") {IF (showMSG); obj.focus (); obj.select (); return false;} else {return true;}} / * ============================================================================================================================================================================================================= ================ Function: Mailbox address check prompt information: No email address or email address is invalid! Use: mailcheck (obj, string) Returns: BOOL ======================================== =======================================, Showmsg) {var show = ifshow (showmsg); if ! = "") {Var ok1 = obj.value.indexof ("@"); var ok2 = obj.value.indexof ("."); If (! (((((Ok1! = - 1) && (ok2! = -1))) {if (showMSG); obj.focus (); obj.select (); return false;} var allowookingtrlist = "& #% <>"; var endvalue = true; for (i = 0; i / * ================================================================================================================================================================ ================== Features: Check if the input is a digital prompt information: not entered or entered is not a legal number! Use: ISNUMERIC (OBJ, STRING) Returns: BOOL ======================================= ===============================================================================================================================================================================================================00 Value.Search (/ ^ (- | / )? $ /)! = -1; if (show && iftrue == false) {Alert (Showmsg); Obj.focus () Obj.select (); return false;} else {return true;}} / * ================================================================================================================================================================ ================== Function: Print use: print () Return: ======================= ===================================================== * / function print () {document.all.print.style.display = "none"; window.print (); window.close (); / * ================================================================================================================================================================ ================== Features: Judgment is the date (format: YYYY-MM-DD) prompt information: the date format error that is not entered or entered! Use: isdate (obj, string) Returns: BOOL ======================================= ========================================, Showmsg) {var show = ifshow == null) {if (showMSG); return false;} if (obj.value == ") {if (showMSG); returnaf (} var datepat = / ^ (/ d) {2} | / d {4} (/ -) (/ D {1, 2}) (/ -) (/ d {1, 2}) $ /; var datestr = obj.value; // is the Format ok? var matcharray = datestR.match (datepat); if (matcharray == null) {if (showMSG); return false;} year = matcharray [1]; month = matcharray [3]; day = Matcharray [5]; IF (Year.Length! = 4 || Month.Length! = 2 || Day.length! = 2) {IF (showMSG); Return False;} IF (Month <1 || Month> 12) {IF (Show) Alert (Showmsg); Return False;} IF (DAY <1 || Day> 31) {IF (Show) Alert (Showmsg); Return False; IF ((Month == 4 || Month == 6 || Month == 9 || Month == 11) && day == 31) {IF (showMSG); Return false;} if (Month = = 2) {var isleap = (Year% 4 == 0 && (Year% 100! = 0 || Year% 400 == 0)); if (DAY> 29 || ((Day == 29) && (! ISLEAP)) {IF (Show) Alert (Showmsg); Return False;}} Return True; / * ================================================================================================================================================================ ================== Function: Date size judgment (format: YYYY-MM-DD) Tip information: The start date of the incoming or input is greater than the end date! Use: Judgedate (OBJ1, OBJ2, STRING) Returns: BOOL ===================================== ====================================== * / function judgedate (Obj1, obj2, showmsg) {var show = ifshow EVA = isdate (Obj1, "") && isdate (Obj2, ""); if (obj1.value! = "" && obj2.value! = "" & evA! = false) {var Date1 = Obj1.value; var MyDate1 = Date.Parse ("-", "/")); var Date2 = obj2.value; var mydate2 = date.parse (Date2.Replace ("-", "/")); if ( MyDate1> mydate2) {if (showMSG); Return False;} else}}}} else {if (show) ALERT (ShowMsg);}}}} / * ================================================================================================================================================================ ================== Function: String operation, remove spaces on both sides of the string: Trim (string) Returns: string =========== ============================================================================================================================================================================================================= ===== * / / * ============================================= ========================= function: Remove the left space to use: Ltrim (String) Returns: string ========== ============================================================================================================================================================================================================= ====== * / function LTRIM (STR) {var white = new string ("/ t / n / r"); var s = new string (STR); IF (Whitespace.indexof (S.Charat (0))! = -1) {var j = 0, i = s.Length; while (j = 0 && Whitespace.indexof (S.Charat) (i))! = -1) {i- -;} s = s.substring (0, i 1); } Return S;} // Remove the front and rear space Function Trim (Str) {RTURN RTRIM (Ltrim (STR));} / * ======================= ==================================================== function: invalid character detection (Not allowed to enter special character) Tips: No input or input containing illegal characters: Checkchar (Obj, lchar, string) LCHAR: Special character to check: BOOL ============= ============================================================================================================================================================================================================= === * / function checkchar (obj, lchar, showmsg) {var show = ifshow (showmsg); Var strlist = lchar; // "~! @ # $% ^ & *? <> /" / '"; // invalid character detection if (obj.value! =") {var TmpBool = true; for ( i = 0; i / * ================================================================================================================================================================ ================== Features: Judgment is an integer, positive integer, negative integer, positive integer 0, negative integer 0 prompt information: parameter error or input is not one (Integer). . Use: Isint (Obj, String, Int or String, String) (Test Object, Or - or Empty, Empty OR 0, Display Information) Empty Integer Positive Integer - Negative Integer Returns: BOOL ======== ============================================================================================================================================================================================================= ======== * / function isint (obj, sign, zero, showmsg) {var show = ifshow (showmsg); var objstr = obj.value; var ra; var bolzero; if (TRIM (OBJSTR) = = "" "{If (show) Alert (Showmsg); obj.focus (); obj.select (); return false;} else {objstr = objstr.tostring ();} if ((Sign == null) | (Trim (Sign) == "" ")) {SIGN =" - ";} IF ((ZERO == Null) || (Trim (ZERO ==")) {bolzero = false;} else { ZERO = ZERO.TOSTRING (); if (zero == 0) {bolzero = true;} else {if (show) ALERT (Showmsg); obj.focus (); obj.select (); returnaf false;}} switch (SIGN) {CASE " -": // Integer REG = / (^ -? | ^ / ?) / d $ /; Case " ": if (! bolzero) {// positive integer REG = / ^ / ? [0-9] * [1-9] [0-9] * $ /;} else {// positive integer 0 // REG = / ^ / ? / D $ /; reg = / ^ / ? [0-9] * [0-9] [0-9] * $ /; } Break; Case "-": if (! Bolzero) {// negative integer REG = / ^ - [0-9] * [1-9] [0-9] * $ /;} else {// negative 0 // reg = / ^ - / d $ /; reg = / ^ - [0-9] * [0-9] [0-9] * $ /;} Break; default: if (show) Alert Showmsg); obj.focus (); obj.select (); returnif;} var r = objstr.match (reg); if (r == null) {if (showMSG); OBJ. FOCUS (); obj.select (); return false;} else {return true;}} / * =========================== ======================================= function: Determine if it is a floating point number, positive floating point , Positive floating point, positive floating point 0, positive floating point 0 prompt information: parameter error or input is not one (floating point). . Use: isfloat (Obj, String, Int or String, String) (Test Object, Or - Or Empty, Empty OR 0, Tips) Parameter 2: Empty floating point positive floating point number - Endo points return: BOOL = ============================================================================================================================================================================================================= ================ * / function isfloat (Obj, Sign, Zero, Showmsg) {var show = ifshow (showmsg); var objstr = obj.value; var ra; var bolzero; IF (TRIM (OBJSTR) == "" "{IF (showMSG); obj.focus (); obj.select (); return false;} else {objstr = objstr.tostring ();} if (SIGN == NULL) || (TRIM (Sign) == "")) {SIGN = " -";} if ((ZERO == Null) || (Trim (ZERO == ")) { Bolzero = false;} else {zero = ZERO.TOSTRING (); if (zero == 0) {bolzero = true;} else {if (show) ALERT (Showmsg); obj.focus (); obj.select () Return false;}}}} switch (sign) {case " -": // floating point number REG = / ^ ((-? | / ?) / D ) (/./ d )? Break; Case " ": if (! bolzero) {// positive floating point REG = / ^ / ? (([0-9] /. [0-9] * [1-9] [0-9 ] *) | ([0-9] * [1-9] [0-9] * /. [0-9] ) | ([0-9] * [1-9] [0-9] * )) $ /;} Else {// positive floating point number 0 reg = / ^ / ? / D (/. / d ) $ /;} Break; Case "-": if (! Bolzero) {/ / linked point number REG = / ^ - (([0-9 ] /. [0-9] * [1-9] *) | ([0-9] * [1-9] [0-9] * /. [0-9] ) | ([0-9] * [1-9] [0-9] *)) $ /;} else {/ / linked point number 0 reg = / ^ ((- / d (/./ D )? ) | (0 (/. 0 ))) $ /;} Break; default: if (show) Alert (Showmsg); obj.focus (); obj.select (); returnaf false; Break;} var R = objstr.match (reg); if (r == null) {if (show) ALERT (ShowMSG); obj.focus (); obj.select (); return false;} else {return true;}}} / * ================================================================================================================================================================ ================== Function: Verify that the ID number is effective prompt information: not entered or enter the ID number is incorrect! Use: isidNo (OBJ, String) Returns: BOOL ======================================= ====================================================================================================================================== 11: "Beijing", 12: "Tianjin", 13: "Hebei", 14: "Shanxi", 15: "Inner Mongolia", 21: "Liaoning", 22: "Heilongjiang", 31: "Shanghai", 32: "Zhejiang", 33: "Anhui", 35: "Fujian", 36: "Jiangxi", 37: "Shandong", 41: "Henan", 42: "Hubei", 42: "Hubei" ", 43:" Hunan ", 44:" Guangdong ", 45:" Guangxi ", 46:" Hainan ", 50:" Chongqing ", 51:" Sichuan ", 52:" Guizhou ", 53:" Yunnan ", 54: "Tibet", 61: "Shaanxi", 62: "Gansu", 63: "Qinghai", 64: "Ningxia", 65: "Xinjiang", 71: "Taiwan", 81: "Hong Kong", 82: "Macau", 91: "Foreign"}; var acity = "11, 12, 13, 14, 15, 21, 22, 23, 36, 37, 33, 34, 35, 36, 37, 41, 42, 43 44, 45, 46, 50, 51, 52, 53, 54, 61, 62, 63, 64, 65, 71, 81, 82, 91 "VAR ISUM = 0; VAR INFO ="; VAR IDCardLength = Obj .value.Length; IF (! / ^ / d {17} (/ d | x) $ / i.test (obj.value) &&! / ^ / d {15} $ / i.test (obj.value)) {i (show) Alert (Showmsg); obj.focus (); obj.select (); return false;} // is equivalent to numbers 10 in the back operation, so convert to a obj.value = obj.value.Replace (/ X $ / i, "a"); var curcity = obj.value.substr (0, 2); if (! (! ({indexof (curcity)> 0)) {if (showMSG); OBJ. Focus (); obj.select (); return false;} IF (IDCardLength == 18) {sbirdhday = obj.value.substr (6,4) " Number (Obj.Value.substr (10, 2)) " - " Number (Obj.Value.substr (12, 2)); var d = new date (sbirdhday.replace (/ - / g, "/")) IF (sbirdhday! = (D.GetfullyEAR () "-" (D.getMonth () 1) "-" D.Getdate ())) {if (showMSG); obj.focus (); obj.select (); return false;} for (var i = 17; i> = 0; I -) ISUM = (Math.Pow (2, I)% 11) * Parseint (Obj.Value.Charat (17 - i), 11); if (ISUM% 11! = 1) {IF ( SHOW) ALERT (Showmsg); obj.focus (); obj.select (); return false;}} else if (idcardLength == 15) {sbpterHDay = "19" Obj.Value.substr (6, 2) "-" Number (Obj.Value.substr (8, 2)) "-" Number (Obj.Value.Substr (10, 2)); var D = new date (SbpterHDay.Replace (/ G) , "/")) VAR DD = d.Getfullyear (). TOSTRING () "-" (D.getMonth () 1) "-" D.Getdate (); IF (SbpterHDay! = DD) {if (showMSG); obj.focus (); obj.select (); return false;}} Return true; / * ================================================================================================================================================================ ================== function: Verify that the phone number format correctly prompt information: not input or enter the phone number format is incorrect! Use: isphoneno (obj, string) Returns: BOOL ======================================= ===============================================================================00 Value; var overvalue = true; var allowstrlist = "1234567890 () -"; if (phoneno! = "") {for (i = 0; i / * ================================================================================================================================================================ ================== function: convert the amount lowercase into Chinese characters to write prompt information: use: Moneytoupper ('zero, 壹,, 叁,, 肆,, 柒, 捌, 玖, 元, 元,,, 仟, 万, 拾,, 仟,, 拾, angle, division, total, zero zero, 100 million, million, zero, zero yuan, zero Corner, zero, ', obj.value return: String str1 = "Zero,,,, 肆, Wu, Lu, Yan, 捌, 玖," str2 = "yuan, pick,, 仟, 仟, Pick,, 仟,, 拾, angle, division, total, zero zero, billion, billion, zero, zero yuan, zero angle, zero, "=========== ============================================================================================================================================================================================================= ===== * / Function MoneyToupper (str1, str2, num) {var charlist1 = str1.split (","); var charlist2 = str2.split (","); for (i = number); ; i> = 0; I -) {// Replace Tomoney () "," Num = Num.Replace (",", ") // Space Num = Num.Replace in Tomoney () "", "")} // Replace the possible 字 character Num = Num.Replace ("¥", "") // Verify that the input character is digital if (isnan (Num)) {Alert ("Error : Not a number! "); Return" ";} // --- Character processing, start conversion, conversion uses the front and rear partial conversion --- var Part = string (num) .split (". "); VAR newchar = ""; // Pre-conversion of for (i = part [0] .length - 1; i> = 0; I -) {// If the quantity exceeds picking up 100 million units, prompt IF (Part [0 ] .length> 10) {Alert ("Error Over Max Length!"); Return "; Var palchar = part [0] .Charat (i); tmpnewchar = charlist1 [perchar] tmpnewchar; var index = part; if (index == 0 || index == 4 || index == 8 || index == 9) {tmpnewchar = tmpnewchar charlist2 [index];} else {if (perchar! = 0) TmpNewchar = tmpnewchar charlist2 [index]; Newchar = tmpnewchar newchar;} // decimal to conversion IF ("String (NUM) .indexof (")! = -1) {if (part [1] .length> 2) {part [1] = Part [1] .substr (0, 2);} for (i = 0; i // Replace zero zero while (newchar.search (charlist2 [13))! = -1) {newchar = newchar.replace (charlist2 [13], charlist1 [0]); // zero newchar = newchar .replace (Charlist2 [14], Charlist2 [8]); // "亿" to "100 million" newchar = newchar.replace (charlist2 [15], charlist2 [8]); // "billion" to "billion "Newchar = newchar.replace (charlist2 [16], charlist2 [4]); //" 万 "to" 10,000 "newchar = newchar.replace (charlist2 [17], charlist2 [0]); //" Zero Yuan "TO" yuan "newchar = newchar.replace (charlist2 [18]," "); //" zero "to" "newchar = newchar.replace (charlist2 [19]," "); //" zero " To "} newchar = newchar.replace (charlist2 [14], charlist2 [8]); //" 亿 "to" 100 million "newchar = newchar.replace (charlist2 [15], charlist2 [8]); ///// "Billion" to "100 million" newchar = newchar.replace (charlist2 [16], charlist2 [4]); // "万" to "10,000" newchar = newchar.replace (charlist2 [17], charlist2 [0] ); // "Zero Yuan" to "yuan" newchar = newchar.replace (charlist2 [18], ""); // "zero" to "" newchar = newchar.replace (charlist2 [19], "" ; // "zero" to "" newchar = newchar charlist2 [12]; //0.6 of the case IF (newchar.indexof (charlist2 [0]) == 0) Newchar = newchar.replace (charlist2 [0], "); return newchar;}