// Whether the verification is null
Function isempty (s ){
VaR lll = trim (s );
If (lll = NULL | lll. Length = 0)
Return true;
Else
Return false;
}
// Delete the space on the left of the string
Function ltrim (STR ){
If (Str. Length = 0)
Return (STR );
Else {
VaR idx = 0;
While (Str. charat (idx). Search (/\ s/) = 0)
Idx ++;
Return (Str. substr (idx ));
}
}
// Delete the space on the right of the string
Function rtrim (STR ){
If (Str. Length = 0)
Return (STR );
Else {
VaR idx = Str. Length-1;
While (Str. charat (idx). Search (/\ s/) = 0)
Idx --;
Return (Str. substring (0, idx + 1 ));
}
}
// Delete spaces on both sides of the string
Function trim (STR ){
Return (rtrim (ltrim (STR )));
}
/* Date comparison */
Function comparedate (date1, date2 ){
If (TRIM (date1) = trim (date2 ))
Return 0;
If (TRIM (date1)> trim (date2 ))
Return 1;
If (TRIM (date1) <trim (date2 ))
Return-1;
}
// Check whether it is email
Function isemail (EML ){
If (TRIM (EML )! = ''){
VaR Re = new Regexp ("@ [\ W] + (\. [\ W] +) + $ ");
Return (Re. Test (EML ));
}
Else
Return (true );
}
// Whether the phone number is used
Function istel (TEL ){
VaR charcode;
For (VAR I = 0; I <Tel. length; I ++)
{
Charcode = Tel. charcodeat (I );
If (charcode <48 & charcode! = 45 | charcode> 57)
Return false;
}
Return true;
}
// Check whether it is a real number
Function isnumber (Num ){
VaR Re = new Regexp ("^ -? [\ D] * \.? [\ D] * $ ");
If (Re. Test (Num ))
Return (! Isnan (parsefloat (Num )));
Else
Return (false );
}
// Check whether the value is an integer.
Function isinteger (Num ){
VaR Re = new Regexp ("^ -? [\ D] * $ ");
If (Re. Test (Num ))
Return (! Isnan (parseint (Num )));
Else
Return (false );
}