// Opt1 decimal opt2 negative
// When opt2 is 1, check if num is negative.
// When opt1 is 1, check whether num is a decimal number.
// 1 is returned and 0 is incorrect.
Function chknbr (Num, opt1, opt2)
{
VaR I = num. length;
VaR staus;
// The number of staus records.
Status = 0;
If (opt2! = 1) & (Num. charat (0) = '-'))
{
// Alert ("You have enter a invalid number .");
Return 0;
}
// An error occurs when the last digit is.
If (Num. charat (I-1) = '.')
{
// Alert ("You have enter a invalid number .");
Return 0;
}
For (j = 0; j <I; j)
{
If (Num. charat (j) = '.')
{
Status;
}
If (status> 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
// Function Description: Check whether the date is used
// Parameter description: the string to be checked
// Return value: 0: Not date 1: Date
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 <lthdatestr; I)
{If (datestr. charat (I) = '-')
{
Status;
}
If (status> 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)
}
If (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 this day! ");
Return 0;
}
Return 1;
}
// Function name: chksafe
// Function Description: Check whether "'",' \ ', "/" is contained "'",'\\',"/"
// Parameter description: the string to be checked
// Return value: 0: Yes 1: No
Function chksafe ()
{
Return 1;
/* Maid = new array ("'","\\",",",",",";","/");
I = maid. length;
J = A. length;
For (II = 0; II <I; ii)
{For (JJ = 0; JJ <j; JJ)
{Temp1 = A. charat (jj );
Temp2 = maid [II];
If (TEM '; P1 = temp2)
{Return 0 ;}
}
}
Return 1;
*/
}
// Function name: chkspc
// Function Description: Check whether space exists.
// Parameter description: the string to be checked
// Return value: 0: Yes 1: No
Function chkspc ()
{
VaR I = A. length;
VaR J = 0;
VaR K = 0;
While (k <I)
{
If (A. charat (k )! = "")
J = J 1;
K = K 1;
}
If (j = 0)
{
Return 0;
}
if (I! = J)
{ return 2 ;}< br> else
{< br> return 1;
}< BR >}