⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jslib.js

📁 基于JAVA的学生就业信息网 实现对信息浏览 检索 审核 修改和删除
💻 JS
字号:

function isBetween(val,lo,hi)
{
       if((val<lo)||(val>hi))
           {return(false);}
       else
          {return(true);}
}
//(6) isEmpty(str)
	function isEmpty(str)
	{
	  //str = str.trim();
	  str = trim(str);
		if((str==null)||(str.length==0))
		{
		  return(true);
		}
		else
		  return(false);
  }
//(2) isDate()

function isDate(theStr)
{
     theStr = trim(theStr);
     var the1st=theStr.indexOf('-');
     var the2nd=theStr.lastIndexOf('-');
     if(the1st==the2nd)
          {  return(false);}
       else
         {
             var y=theStr.substring(0,the1st);
             var m=theStr.substring(the1st+1,the2nd);
             var d=theStr.substring(the2nd+1,theStr.length);
             var maxDays=31;
             if(isInt(m)==false||isInt(d)==false||isInt(y)==false)
             {
             return(false);
             }
             else if(y.length<4)
              { return (false);}
               else if(!isBetween(m,1,12))
              { return (false);}
              else if (m==4||m==6||m==9||m==11)
              maxDays=30;
              else if(m==2)
              {
              if(y%4>0)
              maxDays=28;
              else if(y%100==0&&y%400>0)
              maxDays=28;
              else maxDays=29;

        }
       if(isBetween(d,1,maxDays)==false)
          { return (false);}
       else
              {
              	return (true);
              }
          }
}


function isDate(year, month, day)
{
  if(year.length!=4 || month<1 || month>12)
    return false;
  if(month==4||month==6||month==9||month==11)
  {
    if(day>30)
    return false;
  }
  if(month==2)
  {
    var max=28;
    if((year%100!=0&&year%4==0)||year%400==0)
    var max=29;
    if(day>max || day<1)
    return false;
  }
  return true;
}

//(3) isTime()

function isTime(theStr)
{
  theStr = trim(theStr);
	var colonDex=theStr.indexOf(':');
	if((colonDex<1)||(colonDex>2))
	return(false);
	else
	{
		varhh=theStr.substring(0,colonDex);
             var ss=theStr.substring(colonDex+1,theStr.length);
             if((hh.length<1)||(hh.length>2)||(!isInt(hh)))
             { return (false);}
             else if((ss.length<1)||(ss.length>2)||(!isInt(ss)))
             { return (false);}
             else if ((!isBetween(hh,0,23))|| (!isBetween(ss,0,59)))
             { return (false);}
             else
             { return (true);}


		}
	}
//(4) isDigit(theNum)

	function isDigit(num)
	{
	  if(trim(num)=="")
	    return false;
    var s = "1234567890.-";
    var iCount = num.length;
    for(var i=0;i<iCount;i++)
    {
      if(s.indexOf(num.charAt(i)) < 0)
      return false;
    }
    if(num.indexOf("-")>0)
	    return false;
    return true;
	}
//(5) isEmail(theStr)
	function isEmail(theStr)
	{
	  theStr = trim(theStr);
		var atIndex =theStr.indexOf('@');
		var dotIndex= theStr.indexOf('.',atIndex);
		var flag = true;
		theSub=theStr.substring(0,dotIndex+1);
		if((atIndex<1)||(atIndex!=theStr.lastIndexOf('@'))||(dotIndex<atIndex+2)||(theStr.length<=theSub.length))
		{
			flag = false;
		}
		else
		{
			flag=true;
		}
		return(flag);
	}
//(7) isInt(theStr)
     function isInt(theStr)
     {
       theStr = trim(theStr);
     	 var flag =true;
     	 if(isEmpty(theStr)){flag=false;}
     	 else
           {
     	         for(var i=0;i<theStr.length;i++)
     	         {
     	  	   if(isDigit(theStr.substring(i,i+1))==false)
     	  	       {
     	  	         flag=false;
     	  	         break;
     	  	       }
     	  	 }
     	    }
     	    return(flag);
     }
//(8) isReal(theStr)

     function isReal(theStr)
     	{
     	   theStr = trim(theStr);
     		 var dot1st=theStr.indexOf('.');
     		 var dot2nd=theStr.lastIndexOf('.');
     		 var OK=true;
     		 if(isEmpty(theStr))return false;
     		 if(dot1st==-1)
     		   {
     		 	if(!isInt(theStr))return(false);
     		 	else return(true);

     		    }
     		else if(dot1st!=dot2nd)return(false);
     		else if(dot1st==0)return(false);
     		else
     		      {
     			 var intPart=theStr.substring(0,dot1st);
     			 var decPart=theStr.substring(dot2nd+1);
     			 if(!isInt(intPart)||!isInt(decPart))return(false);
     			 else if(isEmpty(decPart))return(false);
     			 else return(true);
     		      }
     	 }

//(9)过滤空格
     	function trim(theStr)
     	{
     	  while(theStr.length>0 && theStr.lastIndexOf(" ")==(theStr.length-1))
        {
          theStr = theStr.substring(0,theStr.length-1);
        }
        while(theStr.length>0 && theStr.indexOf(" ")==0)
        {
          theStr = theStr.substring(1,theStr.length);
        }
		    return theStr;
		   }
//(10)正实数
      function isPositiveReal(theStr)
      {
        if(!isReal(theStr))
          return false;
        if('-' == theStr.charAt(0))
          return false;
        return true;
      }
//(11)正整数
    	function isPositiveInt(num)
    	{
    	  if(trim(num)=="")
    	    return false;
        var s = "1234567890";
        var iCount = num.length;
        for(var i=0;i<iCount;i++)
        {
          if(s.indexOf(num.charAt(i)) < 0)
          return false;
        }
        if('0' == num.charAt(0))
    	    return false;
        return true;
    	}

//小数
	function isDecimal(num)
	{
	  if(trim(num)=="")
	    return false;
    var s = "1234567890.+";
    var iCount = num.length;
    for(var i=0;i<iCount;i++)
    {
      if(s.indexOf(num.charAt(i)) < 0)
      return false;
    }
    if(num.indexOf("+")>0)
    {
      if(num.indexOf("+")!=0)
	      return false;
    }
    if(num.indexOf(".")<0) return false;
    return true;
	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -