[Original] My JavaScript (2)

xiaoxiao2021-03-06  114

Reprint, please indicate the source and its author feng_sundy My JavaScript (2) function string.prototype.trim () {return this.Replace (/ (^ / s *) | (/ s * $) / g, ""); } Function GF_APPENDZERO (N) {RETURN ("00" n) .SUBSTR (("00" n) .length-2)))))))))))));} // Date Automatic Mounting program //

// Get the current system date time function gf_now () {var fs_now = ""; var fs_return = ""; fs_return = fs_now.getFullyear () "-" GF_APPENDZERO (fs_now.getmonth () 1) " - " GF_APPENDZERO (fs_now.getdate ()); fs_return =" " ": " gf_appendzero (fs_now.getminutes ()) ": " GF_AppendzRo (fs_now.gets ()) ": " GF_APPENDS ()) ": " GF_Appendzro (fs_now.getseconds) )); RETURN FS_RETURN;}

// Get the current system date Function GF_TODAY () {var fs_now = new date (); var fs_return = ""; fs_return = fs_now.getFullyear () "-" GF_APpendzero (fs_now.getmonth () 1) "-" " gf_appendzero (fs_now.getdate ()); return fs_return;}

// Verification date is legal (true / false) function gf_chkdate (as_datestr) {var fs_year = ""; fs_mon = ""; fs_day = ""; fs_time = "; fs_Hour ="; fs_min = ""; fs_sec = ""; fs_obj = "; fs_syn =" "; var fi_loop, fi_len fi_len = as_datestr.length fs_obj =" year "if (fi_len <= 0) Return True; for (Fi_LOOP = 0; fi_loop = 0 && as_datestr.charat (fi_loop) <= 9)) Return False IF (fs_obj == "year") {fs_year = as_datestr.charat (fi_loop)} else if (fs_obj == "month") {fs_mon = as_datestr.charat (fi_loop)} else if (fs_obj == "day" ) {Fs_day = as_datestr.charat (fi_loop)} else if (fs_obj ==

"hour") {if (as_datestr.charat (fi_loop)! = "") fs_Hour = as_datestr.charat (fi_loop)} else if (fs_obj == "minute") {fs_min = as_datestr.charat (fi_loop)} else IF (fs_obj == "second") {fs_sec = as_datestr.Charat (FI_LOOP)}}} // The legitimacy IF (FS_HOUR! = ") {if (fs_min ==") {r (fs_min == ") {return false} Else {if (fs_sec == ") fs_sec =" 0 "} if (fs_HOUR> 24 | | fs_HOUR <0 || fs_min> = 60 || FS_MIN <0 || fs_sec> = 60 || FS_SEC <0) { Return False // Time Error} IF (fs_HOUR.LENGTH> 2) Return false} // Verification date legitimacy if (fs_year == "|| fs_mon ==" || fs_day = = "") Return False; if (fs_year.Length == 2) {fs_year = '20' fs_year;} else if (fs_year.length! = 4) {Return False;}} (fs_year.length> 4 || FS_MON.LENGTH> 2 || FS_DAY.LENGTH> 2) Return false; if (! (fs_year> 1901 && fs_year <2999 && 1 <= fs_mon && 12> = fs_mon && 31> = fs_day && 1 <= fs_day) Return False; if ((fs_mon == 4 || fs_mon == 6 || FS_MON == 9 || fs_mon == 11) && (fs_ Day> 30)) RETURN FALSE; IF ((fs_year% 4 == 0) && (fs_mon == 2) && (fs_day> 29)) Return False; if (! (fs_year% 4 == 0) && (fs_mon = = 2) && (fs_day> 28)) Return False; Return True;

// Verify that only an integer ONKEYPRESSFUNCTION GF_CHECKINT () {IF ((Window.Event.Keycode <48 || Window.Event.KeyCode> 57) && window.event.KeyCode! = 45) Window.Event.ReturnValue = false; } // input validation only real onkeypressfunction gf_checkobjfloat (objectname) {if ((window.event.keyCode <45 || window.event.keyCode> 57 || window.event.keyCode == 47) && window.event.keyCode ! = 45) WINDOW.EVENT.RETURNVALUE = false; if (Window.Event.Keycode == 46 && Objectname.Value.indexof (".")> - 1) Window.Event.ReturnValue = False;}

// Verify that the data cannot be empty // Function GF_MANDATORY (as_prompt) {// AS_PROMPT: TBX_A, can not be empty * TBX_B, can not be empty * var fs_src = as_prompt; var fas_p = fs_src.split ("*"); var Fas_n; for (VAR i = 0; I

/ / Check whether it is a number, decimal function gf_chknum (ai_num) {var Fi_i, FI_J, FI_DOT, STRTEMP; Strtemp = ""; fi_dot = 0; // Decimal number IF (ai_num.tostring (). Length == 0) RETURN FALSE; IF (Ai_Num.Charat (0) == "." | AI_NUM.CHARAT (Ai_Num.Length - 1) == ") Return False; for (Fi_i = 0; Fi_i 1) RETURN FALSE;}}}}} // Remove Space Function GF_TRIM (As_String) {While (as_string.length> 0 && as_string. dengthxof (") == 0) as_string = as_string.substr (1 WHILE (as_string.length> 0 && as_string.lastIndexof (") == (as_string.length-1)) as_string = as_string.substr (0, as_string.length-1); return as_string;}

// You can only enter uppercase characters Function GF_LC2UC () {if (Window.Event.KeyCode> = 97 & window.event.keycode <= 122) {WINDOW.EVENT.KEYCODE = WINDOW.EVENT.KEYCODE - 32;}}

/ ** Format Date Function D - Date 2004-12-25dt - Date Time 2004-12-25 12:05:56 ** / Function GF_FORMATDATE (as_date, as_datetype) {// 2003-11-12 11: 25:13 var fs_tmp = new array (); var fs_date = (as_date == null? ": Gf_trim (as_date)); var fs_datetype = (as_datetype == NULL?" D ":" DT "); if (fs_date == "") Return fs_date; var fi_space = fs_date.indexof (""); var fs_ymd = fs_date.substr (0, fi_space); var fs_hms = fs_date.substr (Fi_Space 1); if (fs_ymd == "" ) {fs_ymd = fs_hms; fs_hms = "";} fs_tmp = fs_ymd.split ("-"); fs_ymd = (fs_tmp [0] .length == 2? ("20" fs_tmp [0]): fs_tmp [0 ]) "-" GF_APPENDZERO (FS_TMP [1]) "-" GF_APPENDZERO (FS_TMP [2]); if (fs_hms! = ") {fs_tmp = fs_hms.split (": "); fs_hms =" " GF_APPENDZERO (FS_TMP [0]) ": " GF_APPENDZERO (fs_tmp.Length == 3? (": " gf_appendzero (fs_tmp [2])):" ");} fs_date = fs_ymd (fs_datetype == "D"? "" ": fs_hms); return fs_date;} // Container box number verification // Author: sundy 20003-4-28 // Format: GF_CHKCNTRNO (as_cntrno, fi_choice) Return (Boolean ) // function: Verify container box number: // parameter: // as_cntrno does not meet international standards, // Return Value: TR The UE is in line with international standards or forced through (special boxes) //: gf_chkcntrno ('texu2982987', 0) function gf_chkcntrno (as_cntrno, ai_choice) {var fi_ki; var fi_numsum; var fi_nummod; var fai_num = new array (11); VAR FB_ERRCNTRNO = FALSE;

IF (as_cntrno == null) return true; // NULL does not verify IF (GF_TRIM (AS_CNTRNO) == ") Return True; // Air does not verify IF (as_cntrno.length == 11) // International standard is 11-bit, the last one is a check bit, if not 11 bits are definitely not a standard box {for (FI_KI = 1; FI_KI <= 11; fi_ki ) FAI_NUM [Fi_Ki] = 0; for (Fi_ki = 1; Fi_Ki <= 4 Fi_ki ) // According to the International Standard Verification, 4 English letters in front of the box number {fch_char = as_cntrno.charat (fi_ki-1) .touppercase (); switch (true) {copy (fch_char == "a"): {FAI_NUM [Fi_Ki] = 10; Break;} case (fch_char> = "v" && fch_char <= "z"): {FAI_NUM [Fi_Ki] = fch_char.charcode () - 52; Break;} case (fch_char> = "L" && fch_char <= "u"): {FAI_NUM [Fi_Ki] = fch_char.charcodeat () - 53; Break;} default: {fai_num [fi_ki] = fch_char.charcodeat () - 54; break;}}} For (FI_KI = 5; Fi_Ki <= 11; Fi_Ki ) {FCH_CHAR = as_cntrno.charat (Fi_Ki-1); Fai_Num [Fi_Ki] = PARSEINT (FCH_CHAR); // CType ((as_cntrno, fi_ki, 1)), Integer}} fi_numsum = 0 for (FI_KI = 1; FI_KI <= 10; FI_KI ) {fi_SQR = 1; for (i = 1; i

/ * Since the REPLACE can only be replaced in JS, the following function can replace 2003.5.13 -sundyas_expression - Sub string as_find-search for the replacement - Springs to be replaced by replacement string functions , such as: " '" into "' '" * / function gf_replace (as_expression, as_find, as_replacement) {var fs_expression = as_expression; var fs_find = as_find; var fs_replacement = as_replacement; if (fs_expression == "") return "" IF (fs_find == "") return "" "; // Constructs regular expression /,, (,), ^, , [,?, ^, | for special characters, must be escaped Alternatively fs_regx1 = gi; fs_find = fs_find.replace (fs_regx1, ""); fs_replacement = fs_replacement.replace (fs_regx1, "//"); fs_regx1 = // $ / gi; fs_find = fs_find.replace (fs_regx1, "// / $ "); fs_replacement = fs_replacement.replace (fs_regx1," / $ "); fs_regx1 = // (/ gi; fs_find = fs_find.replace (fs_regx1," /// ( "); fs_replacement = fs_replacement.replace (fs_regx1 , "/"); Fs_regx1 = ///) / gi; fs_find = fs_find.replace (fs_regx1, "///)"); fs_replacement = fs_replacement.replace (fs_regx1, "/)"); fs_regx1 = // * / gi; fs_find = fs_find.replace (fs_regx1, "/// *" ); Fs_replacement = fs_replacement.replace (fs_regx1, "/ *"); fs_regx1 = // / gi; fs_find = fs_find.replace (fs_regx1, "/// "); fs_replacement = fs_replacement.replace (fs_regx1, "/ "); Fs_regx1 = //./gi; fs_find = fs_find.replace (fs_regx1," ///. "); Fs_replacement = fs_replacement.Replace (fs_regx1," /. "); Fs_regx1 = // [/ gi; FS_FIND = fs_find.replace (fs_regx1, "/// ["); fs_replacement =

Fs_replacement.replace (fs_regx1, "/ ["); fs_regx1 = //? / gi; fs_find = fs_find.replace (fs_regx1, "/////?"); fs_replacement = fs_replacement.Replace (fs_regx1, "/?"); FS_REGX1 = // ^ / GI; fs_find = fs_find.replace (fs_regx1, "/// ^"); fs_replacement = fs_replacement.replace (fs_regx1, "/ ^"); fs_regx1 = // {/ gi; fs_find = fs_find. Replace (fs_regx1, "//// {"); fs_replacement = fs_replacement.replace (fs_regx1, "/ {"); fs_regx1 = // | / gi; fs_find = fs_find.replace (fs_regx1, "//// |"); FS_REPLACEMENT = fs_replacement.replace (fs_regx1, "/ |"); fs_find = "/" fs_find "/ gi"; // Return the replacement value returnif fs_expression.replace (EVAL (fs_find), fs_replacement);}

/* jun.14, 2003--Sundy string converted to numbers ("-> 0) as_type - str, NUM parameter description: as_str - converted string AI_DIGIT - converted decigits (NULL- - Do not limit the number of decimal numbers, 0 - Convert to integer,> 0 Press the decimal number conversion) AS_TYPE - The type returned after the conversion (NULL, "NUM" - converted to a digital type, "str" ​​- conversion For strings (string after fractional formatting), for example: GF_Str2float ("10.2124568795") Returns FLOAT Type 10.2124568795GF_Str2float ("10.6", 0) Returns INT Type 11 (using rounded method) GF_Str2float ("10.2", 2 Returns Float Type 10.1Gf_Str2float ("10.2", 2, "Str") Returns the String Type "10.20" (according to the fractional string) GF_STR2FLOAT ("10.216", 2) Returns FLOAT Type 10.22GF_Str2float ("10.216" 2, "STR") Returns the string type "10.22" * / function gf_str2float (as_Str, ai_digit, as_type) {var fdb_tmp = 0; var fi_digit = 0; var fs_digit = "1"; var fs_str = "" as_str; VAR fs_tmp1 = ""; var fs_tmp2 = ""; var fi_pos = 0; var fi_len = 0; fdb_tmp = parsefloat (isnan (paraSefloat)? 0: fs_str); switch (TRUE) {case (ai_digit == null ): // does not change the value, only convert to digital fdb_tmp = fdb_tmp; break; case (ai_digit == 0): // acquire integer fdb_tmp = math.Round (fdb_tmp); Break; case (ai_digit> 0): // Funded by the number of points in the number of points, rounded values ​​for (V Ar i = 0; I

} Break;} Return FDB_TMP;} // Print Data Function GF_DGDPRINT (as_reportname, as_where, as_subtitle, as_footer) {// Print DataGrid - Sherry 2003-08-19 / * as_reportname - Report Format Name Can't empty as_where - WHERE extraction conditions, like "from code_driver where corp= 'this unit" can't be empty as_subtitle - Header Title as_footer - Type, * / var fs_rpt_property = "width =" (Screen.Width - 10) "Height =" (Screen.Height - 55) ", Left = 0, TOP = 0"; if (as_reportname == NULL) as_reportname = ""; if (as_where == null) as_where = ""; IF (as_subtitle == null) as_subtitle = ""; if (as_footer == null) as_footer = ""; var S_Rpt_ReportName = escape (as_reportname); var S_Rpt_Where = escape (as_where); var S_Rpt_SubTitle = escape (as_subtitle); var S_Rpt_Footer = escape (as_footer); var fs_parm = ""; fs_parm = "S_Rpt_ReportName =" S_Rpt_ReportName; fs_parm = "? & S_Rpt_Where =" S_Rpt_Where; fs_parm = "& S_Rpt_SubTitle =" S_Rpt_SubTitle; fs_parm = "& S_Rpt_Footer =" S_rpt_footer; window.open ("../syspublic/sys_printer.aspx" fs_parm, "sys_printer", FS_RPT_PRO }

转载请注明原文地址:https://www.9cbs.com/read-100104.html

New Post(0)