JS Judging the words of Chinese characters//**************************************************************** //* Name: Datalength//* Function: Calculate the length of the data//* Entry Parameters: FData: Data to be calculated//* Exit Parameters: Returns the length of the Fdata (Unicode length is 2, non-Unicode length is 1)//***************************************************************** functiondatalength (fData) {varIntlength=0 for(vari=0;i<fdata.length;i++) { if((Fdata.charcodeat (i) < 0) | | (Fdata.charcodeat (i) > 255)) Intlength=intlength+2Elseintlength=intlength+1 } returnIntlength}//**************************************************************** //* Name: IsEmpty//* Function: Determine whether it is empty//* Entry parameter: FData: The data to be checked//* Export parameter: True: null//* False: Non-empty//***************************************************************** functionIsEmpty (fData) {return((fdata==NULL) || (fdata.length==0) ) } //**************************************************************** //* Name: IsDigit//* Function: Judge whether it is a number//* Entry parameter: FData: The data to be checked//* Export parameters: True: Numbers from 0 to 9//* False: Not a number from 0 to 9//***************************************************************** functionIsDigit (fData) {return((fdata>= "0") && (fdata<= "9"))) } //**************************************************************** //* Name: Isinteger//* Function: Determine whether a positive integer//* Entry parameter: FData: The data to be checked//* Export parameter: True: is an integer, or the data is empty//* False: not an integer//***************************************************************** functionIsinteger (fData) {//if NULL, returns True if(IsEmpty (fData))return true if((IsNaN (fData)) | | (Fdata.indexof (".")! =-1) | | (Fdata.indexof ("-")!=-1)) return false return true } //**************************************************************** //* Name: Isemail//* Function: To determine whether the correct email address//* Entry parameter: FData: The data to be checked//* Export Parameters: true: The correct email address, or empty//* false: Wrong email address//***************************************************************** functionIsemail (fData) {if(IsEmpty (fData))return true if(Fdata.indexof ("@") ==-1) return false varNamelist=fdata.split ("@"); if(namelist.length!=2) return false if(namelist[0].length<1 ) return false if(Namelist[1].indexof (".") <=0) return false if(Fdata.indexof ("@") >fdata.indexof ("."))) return false if(Fdata.indexof (".") ==fdata.length-1) return false return true } //**************************************************************** //* Name: Isphone//* Function: Determine whether the correct phone number (can contain "()", "()", "+", "-" and space)//* Entry parameter: FData: The data to be checked//* Export Parameters: true: Correct phone number, or empty//* false: Wrong phone number//* error message://***************************************************************** functionIsphone (fData) {varstr; varFdatastr= ""; if(IsEmpty (fData))return true for(vari=0;i<fdata.length;i++) {str=fdata.substring (i,i+1); if(str!= "(" && str!= ")" && str!= "(" && str!= ")" && str!= "+" && str!= "-" && s Tr!= "") Fdatastr=fdatastr+str; } //alert (FDATASTR); if(IsNaN (FDATASTR))return false return true } //**************************************************************** //* Name: Isplusnumeric//* Function: Determine whether the correct positive number (can include the decimal part)//* Entry parameter: FData: The data to be checked//* Export Parameters: true: Correct positive number, or empty//* false: Incorrect positive number//* error message://***************************************************************** functionIsplusnumeric (fData) {if(IsEmpty (fData))return true if((IsNaN (fData)) | | (Fdata.indexof ("-")!=-1)) return false return true } //**************************************************************** //* Name: IsNumeric//* Function: Determine whether it is the correct number (can be negative, decimal)//* Entry parameter: FData: The data to be checked//* Export Parameters: true: Correct number, or null//* false: Wrong number//* error message://***************************************************************** functionIsNumeric (fData) {if(IsEmpty (fData))return true if(IsNaN (fData))return false return true } //**************************************************************** //* Name: Isintegerinrange//* Function: Determine whether a number is within the specified range//* Entry parameter: finput: The data to be checked//* FLower: Check the lower limit of the range, if there is no lower limit, please use null//* FHigh: Check the upper limit, if there is no upper limit, please use null//* Export parameters: True: Within the specified range//* False: Beyond the specified range//***************************************************************** functionIsintegerinrange (finput,flower,fhigh) {if(flower==NULL) return(finput<=FHigh)Else if(fhigh==NULL) return(finput>=fLower)Else return((Finput>=flower) && (finput<=FHigh)) }