/*------------------------
功能:替换任何空白字符
-------------------------*/
function TrimString (strVal)
{
strTmp = strVal + "";
if (strTmp.length == 0)
return (strTmp);
reVal = /^/s*/;
strTmp = strTmp.replace (reVal, '');
reVal = //s*$/;
return (strTmp.replace (reVal, ''));
}
/*------------------------
功能:检测是否是有效数字
-------------------------*/
function Check_Num( num )
{
num = ( TrimString( num ) );
if (num.length == 0)
return (false);
return ( Number( num ) );
}
/*------------------------
功能:检测是否是有效 日期
-------------------------*/
function Check_Date (strDate)
{
strDate = (TrimString (strDate));
if (strDate.length == 0)
return (false);
reVal = /^([1-2]/d{3})[//|/-](0?[1-9]|10|11|12)[//|/-]([1-2]?[0-9]|0[1-9]|30|31)$/;
return (reVal.test (strDate));
}
/*------------------------
功能:检测是否是有效Email
-------------------------*/
function Check_Email (strEmail)
{
strEmail = (TrimString (strEmail));
if (strEmail.length == 0)
return (false);
reVal = /^[/-!#/$%&'/*/+///.//0-9=/?A-Z/^_`a-z{|}~]+@[/-!#/$%&'/*/+///.//0-9=/?A-Z/^_`a-z{|}~]+(/.[/-!#/$%&'/*/+///.//0-9=/?A-Z/^_`a-z{|}~]+)+$/;
return (reVal.test (strEmail));
}
/*------------------------
功能:检测是否是有效时间
-------------------------*/
function Check_Time (strTime)
{
strTime = (TrimString (strTime));
if (strTime.length == 0)
return (false);
reVal = /^(([0-9]|[01][0-9]|2[0-3])(:([0-9]|[0-5][0-9])){0,2}|(0?[0-9]|1[0-1])(:([0-9]|[0-5][0-9])){0,2}/s?[aApP][mM])?$/;
return (reVal.test (strTime));
}
/*------------------------
功能:检测是否是有效 日期特定格式
-------------------------*/
function Check_Date_1 (strDate)
{
strDate = (TrimString (strDate));
if (strDate.length == 0)
return (false);
reVal = /^([1-2]/d{3})[//](0?[1-9]|10|11|12)[//]([1-2]?[0-9]|0[1-9]|30|31)$/;
return (reVal.test (strDate));
}
/*------------------------
功能:检测是否是有效 日期特定格式
-------------------------*/
function Check_Date_2 (strDate)
{
strDate = (TrimString (strDate));
if (strDate.length == 0)
return (false);
reVal = /^([1-2]/d{3})[/-](0[1-9]|10|11|12)[/-]([1-2][0-9]|0[1-9]|30|31)$/;
return (reVal.test (strDate));
}
/*--------------------------------------
功能:换行定行
---------------------------------------*/
function enter( form, temp )
{
if ( window.event.keyCode == 13 )
{
eval( form + temp + ".focus()" );
eval( form + temp + ".select()" );
}
else
return (false);
}
/*--------------------------------------
功能:检查字符串长度
---------------------------------------*/
function ByteString (strVal)
{
nLen = 0;
for (i = 0; i < strVal.length; i ++)
{
if (strVal.charCodeAt (i) > 255)
nLen += 2;
else
nLen ++;
};
return (nLen);
}
/*--------------------------------------
功能:按要求截取字符串长度
---------------------------------------*/
function SubString(strVal,nStrLen)
{
nLen = 0;
nTemp = 0;
for (i = 0; i < strVal.length; i ++)
{
if (strVal.charCodeAt (i) > 255)
nLen += 2;
else
nLen ++;
if(nLen <= nStrLen)
nTemp = i;
else
break;
};
return(strVal.substr(0,nTemp+1));
}
/*------------------------
功能:检测密码,密码只能由英文字母、数字、减号、下划线、$、#、*、(和)构成,且首位必须是英文字母
-------------------------*/
function Check_Pass( strPass )
{
strPass = ( TrimString( strPass ) );
if (strPass.length == 0)
return (false);
reVal = /^[a-zA-Z]{1}[a-zA-Z0-9-_$#*()]{0,29}$/;
return ( reVal.test (strPass) );
}