/***************************************************
* EO_JSLibjs
* javascript正则表达式检验
*******************************************************/
//校验是否全由数字组成
function isDigit(s)
{
var patrn=/^[]{}$/;
if (!patrnexec(s)) return false
return true
}
//校验登录名只能输入个以字母开头可带数字_的字串
function isRegisterUserName(s)
{
var patrn=/^[azAZ]{}([azAZ]|[_]){}$/;
if (!patrnexec(s)) return false
return true
}
//校验用户姓名只能输入个以字母开头的字串
function isTrueName(s)
{
var patrn=/^[azAZ]{}$/;
if (!patrnexec(s)) return false
return true
}
//校验密码只能输入个字母数字下划线
function isPasswd(s)
{
var patrn=/^(\w){}$/;
if (!patrnexec(s)) return false
return true
}
//校验普通电话传真号码可以+开头除数字外可含有
function isTel(s)
{
//var patrn=/^[+]{}(\d){}[ ]?([]?(\d){})+$/;
var patrn=/^[+]{}(\d){}[ ]?([]?((\d)|[ ]){})+$/;
if (!patrnexec(s)) return false
return true
}
//校验手机号码必须以数字开头除数字外可含有
function isMobil(s)
{
var patrn=/^[+]{}(\d){}[ ]?([]?((\d)|[ ]){})+$/;
if (!patrnexec(s)) return false
return true
}
//校验邮政编码
function isPostalCode(s)
{
//var patrn=/^[azAZ]{}$/;
var patrn=/^[azAZ ]{}$/;
if (!patrnexec(s)) return false
return true
}
//校验搜索关键字
function isSearch(s)
{
var patrn=/^[^`~!@#$%^&*()+=|\\\][\]\{\}:;\\<>/?]{}[^`~!@$%^&()+=|\\\][\]\{\}:;\\<>?]{}$/;
if (!patrnexec(s)) return false
return true
}
function isIP(s) //by zergling
{
var patrn=/^[]{}$/;
if (!patrnexec(s)) return false
return true
}
/*************************************************
* FUNCTION: isBetween
* PARAMETERS: val AS any value
* lo AS Lower limit to check
* hi AS Higher limit to check
* CALLS: NOTHING
* RETURNS: TRUE if val is between lo and hi both inclusive otherwise false
***************************************************/
function isBetween (val lo hi) {
if ((val < lo) || (val > hi)) { return(false); }
else { return(true); }
}
/************************************************
* FUNCTION: isDate checks a valid date
* PARAMETERS: theStr AS String
* CALLS: isBetween isInt
* RETURNS: TRUE if theStr is a valid date otherwise false
*************************************************/
function isDate (theStr) {
var thest = theStrindexOf();
var thend = theStrlastIndexOf();
if (thest == thend) { return(false); }
else {
var y = theStrsubstring(thest);
var m = theStrsubstring(thest+thend);
var d = theStrsubstring(thend+theStrlength);
var maxDays = ;
if (isInt(m)==false || isInt(d)==false || isInt(y)==false) {
return(false); }
else if (ylength < ) { return(false); }
else if (!isBetween (m )) { return(false); }
else if (m== || m== || m== || m==) maxDays = ;
else if (m==) {
if (y % > ) maxDays = ;
else if (y % == && y % > ) maxDays = ;
else maxDays = ;
}
if (isBetween(d maxDays) == false) { return(false); }
else { return(true); }
}
}
/**********************************************
* FUNCTION: isEuDate checks a valid date in British format
* PARAMETERS: theStr AS String
* CALLS: isBetween isInt
* RETURNS: TRUE if theStr is a valid date otherwise false
*************************************************/
function isEuDate (theStr) {
if (isBetween(theStrlength ) == false) { return(false); }
else {
var thest = theStrindexOf(/);
var thend = theStrlastIndexOf(/);
if (thest == thend) { return(false); }
else {
var m = theStrsubstring(thest+thend);
var d = theStrsubstring(thest);
var y = theStrsubstring(thend+theStrlength);
var maxDays = ;
if (isInt(m)==false || isInt(d)==false || isInt(y)==false) {
return(false); }
else if (ylength < ) { return(false); }
else if (isBetween (m ) == false) { return(false); }
else if (m== || m== || m== || m==) maxDays = ;
else if (m==) {
if (y % > ) maxDays = ;
else if (y % == && y % > ) maxDays = ;
else maxDays = ;
}
if (isBetween(d maxDays) == false) { return(false); }
else { return(true); }
}
}
}
/**************************************************
* FUNCTION: Compare Date! Which is the latest!
* PARAMETERS: lessDatemoreDate AS String
* CALLS: isDateisBetween
* RETURNS: TRUE if lessDate<moreDate
****************************************************/
function isComdate (lessDate moreDate)
{
if (!isDate(lessDate)) { return(false);}
if (!isDate(moreDate)) { return(false);}
var lessst = lessDateindexOf();
var lessnd = lessDatelastIndexOf();
var morest = moreDateindexOf();
var morend = moreDatelastIndexOf();
var lessy = lessDatesubstring(lessst);
var lessm = lessDatesubstring(lessst+lessnd);
var lessd = lessDatesubstring(lessnd+lessDatelength);
var morey = moreDatesubstring(morest);
var morem = moreDatesubstring(morest+morend);
var mored = moreDatesubstring(morend+moreDatelength);
var Date = new Date(lessylessmlessd);
var Date = new Date(moreymoremmored);
if (Date>Date) { return(false);}
return(true);
}
/**********************************************
* FUNCTION isEmpty checks if the parameter is empty or null
* PARAMETER str AS String
*************************************************/
function isEmpty (str) {
if ((str==null)||(strlength==)) return true;
else return(false);
}
/***********************************************
* FUNCTION: isInt
* PARAMETER: theStr AS String
* RETURNS: TRUE if the passed parameter is an integer otherwise FALSE
* CALLS: isDigit
***************************************************/
function isInt (theStr) {
var flag = true;
if (isEmpty(theStr)) { flag=false; }
else
{ for (var i=; i<theStrlength; i++) {
if (isDigit(theStrsubstring(ii+)) == false) {
flag = false; break;
}
}
}
return(flag);
}
/*****************************************************
* FUNCTION: isReal
* PARAMETER: heStr AS String
decLen AS Integer (how many digits after period)
* RETURNS: TRUE if theStr is a float otherwise FALSE
* CALLS: isInt
*******************************************************/
function isReal (theStr decLen) {
var dotst = theStrindexOf();
var dotnd = theStrlastIndexOf();
var OK = true;
if (isEmpty(theStr)) return false;
if (dotst == ) {
if (!isInt(theStr)) return(false);
else return(true);
}
else if (dotst != dotnd) return (false);
else if (dotst==) return (false);
else {
var intPart = theStrsubstring( dotst);
var decPart = theStrsubstring(dotnd+);
if (decPartlength > decLen) return(false);
else if (!isInt(intPart) || !isInt(decPart)) return (false);
else if (isEmpty(decPart)) return (false);
else return(true);
}
}
/*****************************************************
* FUNCTION: isEmail
* PARAMETER: String (Email Address)
* RETURNS: TRUE if the String is a valid Email address
* FALSE if the passed string is not a valid Email Address
* EMAIL FORMAT: AnyName@EmailServer eg; w
* @ sign can appear only once in the email address
*******************************************************/
function isEmail (theStr) {
var atIndex = theStrindexOf(@);
var dotIndex = theStrindexOf( atIndex);
var flag = true;
theSub = theStrsubstring( dotIndex+)
if ((atIndex < )||(atIndex != theStrlastIndexOf(@))||(dotIndex < atIndex + )||(theStrlength <= theSublength))
{ return(false); }
else { return(true); }
}
/********************************************************
* FUNCTION: newWindow
* PARAMETERS: doc > Document to open in the new window
hite > Height of the new window
wide > Width of the new window
bars > Scroll bars = YES Scroll Bars = NO
resize > Resizable = YES Resizable = NO
* CALLS: NONE
* RETURNS: New window instance
*************************************************************/
function newWindow (doc hite wide bars resize) {
var winNew=_blank;
var opt=toolbar=location=directories=status=menubar=;
opt+=(scrollbars=+bars+);
opt+=(resizable=+resize+);
opt+=(width=+wide+);
opt+=(height=+hite);
winHandle=windowopen(docwinNewopt);
return;
}
/***********************************************************
* FUNCTION: DecimalFormat
* PARAMETERS: paramValue > Field value
* CALLS: NONE
* RETURNS: Formated string
***************************************************************/
function DecimalFormat (paramValue) {
var intPart = parseInt(paramValue);
var decPart =parseFloat(paramValue) intPart;
str = ;
if ((decPart == ) || (decPart == null)) str += (intPart + );
else str += (intPart + decPart);
return (str);
}
^\\d+$//非负整数(正整数 + )
^[]*[][]*$//正整数
^((\\d+)|(+))$//非正整数(负整数 + )
^[]*[][]*$//负整数
^?\\d+$//整数
^\\d+(\\\\d+)?$//非负浮点数(正浮点数 + )
^(([]+\\[]*[][]*)|([]*[][]*\\[]+)|([]*[][]*))$//正浮点数
^((\\d+(\\\\d+)?)|(+(\\+)?))$//非正浮点数(负浮点数 + )
^((([]+\\[]*[][]*)|([]*[][]*\\[]+)|([]*[][]*)))$//负浮点数
^(?\\d+)(\\\\d+)?$//浮点数
^[AZaz]+$//由个英文字母组成的字符串
^[AZ]+$//由个英文字母的大写组成的字符串
^[az]+$//由个英文字母的小写组成的字符串
^[AZaz]+$//由数字和个英文字母组成的字符串
^\\w+$//由数字个英文字母或者下划线组成的字符串
^[\\w]+(\\[\\w]+)*@[\\w]+(\\[\\w]+)+$//email地址
^[azAz]+://(\\w+(\\w+)*)(\\(\\w+(\\w+)*))*(\\?\\S*)?$//url