// 检测文本框内容的长度在minLingth和maxLength之间

function chkLength(field, msg, minLength, maxLength)
{
	if(!minLength) minLength =1;
	if (field.value.length < minLength) {
		if(msg) alert(msg);
		return(false);
	}	else {
	
	    if(maxLength) {
		      if (field.value.length>maxLength) {
			  if(msg) alert(msg)
			  return(false)
			  }
			  return(true)
		}
	
	return(true);
	}
}

// 检测指定字符串是否由指定字符组成 

function chkAlpha(field, notlimit, msg){
    isok="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"+notlimit;
	
	for (i=1;i<field.value.length+1;++i){
	     ai=field.value.substring(i-1,i);
         if (isok.indexOf(ai,0)<0) { if(msg) alert(msg);return(false)};
	}
	
	return(true);
}

// 检测指定字符串不能由指定字符组成 

function chkAlpha2(field,limit,msg){
    for (i=1;i<field.value.length+1;++i){
	     ai=field.value.substring(i-1,i);
         if (limit.indexOf(ai,0)>-1) { if(msg) alert(msg);return(false)};
	}
	
	return(true);
}

function chkNumber(field, msg){
    isok="0123456789";
	
	for (i=1;i<field.value.length+1;++i){
	     ai=field.value.substring(i-1,i);
         if (isok.indexOf(ai,0)<0) { if(msg) alert(msg);return(false)};
	}
	
	return(true);
}

function is_same(field1,field2,msg){
     if (field1.value.toLowerCase()==field2.value.toLowerCase()) {return(true)}
	 else {if(msg) alert(msg);return(false)}
}

function is_email(field,msg) {
	var foundAta = field.value.indexOf("@",0);
        var foundAtb = field.value.indexOf(".",0);
   if (foundAta < 1 || foundAtb < 1 ) 
   {
	  if(msg) alert(msg);
      return(false);
	}
	return(true);
	}
