Some of the JavaScript functions that I organize it will be used by friends from beginners.

xiaoxiao2021-03-06  93

Keyword JavaScript, Data Detection // Function Name: Chksafe // Features: Check if "'",' // ', "/" // Parameter Description: String // Return Value: 0: Yes 1: Not Function Chksafe (a) {Return 1; / * fibdn = New Array ("'", "//", ",", ",", ";", "/"); i = fibdn.length ; J = a.length; for (ii = 0; II

// Function name: Chkspc // function introduction: Check if it contains space // parameter description: The string to check // return value: 0: Yes 1: not function chkspc (a) {var i = a.length; var J = 0; var k = 0; while (k

// Function Name: Chkemail // Features: Check if the email address // Parameter Description: String // Return Value: 0: Not 1: Yes Function Chkemail (a) {var i = a.length; Var Temp = a.indexof ('@'); var tempd = a.indexof ('.'); if (Temp> 1) {if ((i-temp)> 3) {if ((i-tempd)> 0) {RETURN 1;}}}}}}}}}}} Return 0;

// OPT1 decimal OPT2 negative number // Check NUM if the OPT2 is 1:// When the OPT1 is 1, check whether NUM is decumbion // Return 1 is correct, 0 is the wrong Function CHKNBR (Num, OPT1, OPT2 ) {Var i = Num.length; var staus; // staus is used to record. The number status = 0; IF ((OPT2! = 1) && (Num.Charat (0) == '-')) { // Alert ("You Have Enter A Invalid Number."); Return 0;} // When the last bit is. Error IF (Num.Charat (I-1) == '.') {// alert "You Have Enter a invalid Number."); Return 0;}

For (j = 0; j 1) {// alert ("You Have Enter A Invalid Number. "); RETURN 0;} IF (Num.Charat (j) <'0' || Num.Charat (j)> '9') {IF (((OPT1 == 0) || (Num.Charat (J )! = '.')) && (j! = 0)) {// Alert ("You Have Enter a invalid number."); return 0;}}} Return 1;} // Function Name: chkdate // Features: Check if the date // Parameter Description: String // Return Value: 0: Not Date 1: Yes Function Chkdate (DateStr) {var lthdateStr if (DateStr! = ") LTHDATESTR = DateStr. Length; else lthdatestr = 0; var tmpy = "; var tmpm =" "; var TMPD =" "; // var datestr; var status; status = 0; if (lthdatestr == 0) Return 0

For (i = 0; i 2) {// Alert ("Invalid Format Of Date!") Return 0;} IF ((status == 0) && (DateStr.Charat (i)! = '-')) {tmpy = tmpy dateStr.Charat (i)} IF ((status == 1) && DateStr.Charat (i)! = '-')) {TMPM = TMPM DATESTR.CHARAT (i)} f ((status == 2) && (dateStr.Charat (i)! = '-') {TMPD = TMPD DATESTR.CHARAT (I)}

} Year = new string (tmpy); Month = new string (tmpm); day = new string (tmpd) ​​// tempdate = new string (YEAR MONTH DAY); // Alert (Tempdate); if (((TMPY). Length! = 4) || (TMPM.LENGTH> 2) || (TMPD.LENGTH> 2)) {// Alert ("Invalid Format Of Date!"); Return 0;}} IF (! (1 <= Month) && (12> = month) && (31> = day) && (1 <= day))) {// Alert ("Invalid Month or Day!"); return 0;} if (! ("(Year%) 4) == 0) && (MONTH == 2) && (DAY == 29)) {// Alert ("this is not a leap year!"); Return 0;} IF ((Month <= 7) && ((MONTH% 2) == 0) && (day> = 31)) {// Alert ("this Month Is A SMALL MONTH!"); return 0;} IF ((Month> = 8) && ((Month) % 2) == 1) && (day> = 31)) {// Alert ("this Month Is A SMALL MONTH!"); Return 0;} IF ((MONTH == 2) && (day == 30) ) {// Alert ("THE Febryary NEVER HAS DAY!"); Return 0;} Return 1;} // function name: fucpwdchk // function introduction: Check if there is a non-numeric or letter // parameter description: To check // string return value: 0: 1 comprising: all numbers or letters function fucPWDchk (str) {var strSource = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; var ch; var i; var temp; for (i = 0; i <= ( Str.l ENGTH-1); i ) {ch = str.Charat (i); temp = strsource.indexof (ch); if (Temp == - 1) {RETURN 0;}} IF (strsource.indexof (ch) == -1) {return 0;} else {return 1;}}

Function Jtrim (STR) {while (str.charat (0) == "") {str.sustr (1);} while (str.charat (str.length-1) == "") {str = Str.Substr (0, str.Length-1);} return (str);} // function name: fucchecknum // function introduction: Check if it is a number // parameter description: To check the number // return value: 1 In order to be a number, 0 is not digital function fucchecknum (num) {var i, j, strTemp; startemp = "0123456789"; if (num.length == 0) Return 0 for (i = 0; i

// Function name: fucchecktel // function introduction: Check if the phone number // parameter description: The string // return value to check: 1 is legal, 0 is the illegal function fucchecktel (tel) {var i, j , strtemp; strTemp = "0123456789 - () #"; for (i = 0; i

// Function name: Fucchecklength // function introduction: Check the length of the string // Parameter Description: String // Return Value: Length value Function Fucchecklength (strTemp) {var i, sum; sum = 0; for i = 0; i = 0) && (Strtemp.Charcodeat (i) <= 255)) SUM = SUM 1; Else Sum = SUM 2;}}}} // function name: getFileSize // function introduction: Take the size of the file // Parameter description: File path // Return value: File size: Yes file does not exist: not function getFilesis (filepath) { Var path = filepath; var fiLesize = ""; var fso = new activityXObject ("scripting.filesystemObject"); if (fso.fileexists (path)) {var file = fso.getfile (path); filesis = parseint (file. Size / 1024) "k";} else {filesize = "file does not exist!";}} // function name: HomePage // function introduction: Set the current page for the main page // Parameter Description: URLFunction HomePage (URL) { This.Style.behavior = "URL (# default # homepage"; this.sethomepage (URL);} // Function name: jionsouc // Function introduction: Add to Favorites // Parameter Description: URL, Website Description Function JionSouc URL, DISPLAY) {Window.external.Addfavorite (URL, Display)} // Function Name: FilTerTyPE // Features: Filter suffix does not for the BMP, JPG, GIF upload file // parameter is an object of the upload component .Function FilterType (OBJ) {// file name, acquire file extension var REG = / ([^.] ) $ /. EXEC (OBJ.VALUE); STYP E = regexp. $ 1; if (! / (jpg | gif | bmp) $ / ip.test (stype)) {Alert ("Please select BMP, JPG, GIF file!"); obj.select (); document. Execcommand ("delete");}}

// Function name: Dozoom // function introduction: Change the font in the page. Such as the size of the article font. The ID name of the page is taken to the page. Size is the font size function dozoom (ID, size) {document.getlementByid ( ID) .Style.FontSize = size "px"}

// Function Name: ISEMAIL // Features: Verify that the value entered by the page is email format. // Parameter: Parameter is the input string function ISemail (String) {if (String.Search (/ ^ / w - / w ) | (/./ w )) * / @ [A-ZA-Z0-9] (/. | -) [A-ZA-Z0-9] ) * /. [A-ZA -z0-9] $ /)! = -1) Return true; else returnaf false;}

// Function Name: Round // Features: Since the rounded function. // Parameter: V is the number taken, P is the number of bits behind the decimal point. Function Round (V, P) {Var Tempint, Tempdot, Temp, Power , xxrl temp = v; power = 1; for (var i = 0; i = 0.499) {Tempint = Tempint 1;} xxrl = parsefloat (Tempint / Power, 4);

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

New Post(0)