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

📄 utl.js

📁 本系统的使用可以将工作的部分流程使用计算机的办公自动化处理
💻 JS
📖 第 1 页 / 共 2 页
字号:
/**********************
10.判断输入浮点数串
***********************/
function check_number_point(num,x,y)
{
	var num1="";
	var num2="";
	var flag=0;
	var m=0+x;
	var n=0+y;
	var chk1,chk2;
	flag=num.indexOf('.',0);
	if(flag==-1) flag=num.length;
	num1=num.substring(0,flag);
	chk1=check_number_maxlength(num1,m);
	if(flag<num.length)
	{
	num2=num.substring(++flag,num.length);
	chk2=check_number_maxlength(num2,n);
	if(chk2!='0')
	return(chk2);
	}
	if(chk1!='0')
	return(chk1);
	return('0');
}
/**************************
11.判断输入的字符串是否为空
***************************/

function check_item_null(num)
{
	if (num.length==0)
	  return  (true);
	  	else
	  return (false) ;
}

function getCurrentDate()
{
    var currDate,strDate;
    var year,month,day;
    currDate = new Date();
    year = currDate.getYear();
    month = currDate.getMonth()+1;
    day = currDate.getDate();
    if(month<10)
        month="0"+month;
    if(day<10)
      day="0"+day;
    strDate = year+"."+month+"."+day;
    return strDate;
}

/**************************
13.判断输入串全部是字母
***************************/

function check_c(str)
{
	for(i=0;i<str.length;i++)
	{
		var a=str.substr(i,1);
		if (a<'A' || (a>'Z' && a<'a') || a>'z')
		return('1');
	}
	return('0');
}

/**********************************************************
14. 若身份证为空,返回0;其他的不合法情况返回负值;如果合法返回1;
**********************************************************/
function _checkSfzh(sfzh)
{
	var val = sfzh;
	var ret ="";
	if(val.length == 0)
		return 0;
	if(check_number(val) == '1')
	{
		alert("公民身份号码只能是数字!");
		return -3;
	}
	if(val.length!=15 && val.length!=18 )
	{
		alert("公民身份号码应为15位或18位!");
		return -1;
	}
	else if(val.length == 15 )
    {
		var birthday = "19" + val.substring(6,8) + "." + val.substring(8,10) + "." +val.substring(10,12);
		var sex = parseInt(val.substring(14,15));
		ret = check_date(birthday,"D");
		if(ret != "")
		{
			alert("公民身份号码7-12位应是日期格式!");
			return -2;//日期格式不对
        }
    }
    else if(val.length == 18 )
    {
		var birthday = val.substring(6,10) + "." + val.substring(10,12) + "." +val.substring(12,14);
		var sex = parseInt(val.substring(16,17));
		ret = check_date(birthday,"D");
		if(ret != "")
		{
			alert("公民身份号码7-14位应是日期格式!");
			return -2;//日期格式不对
        }
    }
	return 1;
}

/*******************************************************
15. 若申请表编号为空,返回0;其他的不合法情况返回负值;如果合法返回1;
********************************************************/
function _checkSqbbh(sqbbh)
{
	var val = sqbbh;
	if(val.length==0)
		return 0;
	if(val.length!=12)
	{
		alert("申请表编号应为12位!请检查您的输入");
		return -1;
	}

	var pre = val.substr(0, 4);
	var mid = val.substr(4, 1);
	var re  = val.substr(5, 7);

	if(check_number(pre) == '1')
	{
		alert("申请表编号前4位应为数字!");
		return -2;
	}else if(check_c(mid) == '1')
	{
		alert("申请表编号第5位应为字母!");
		return -3;
	}else if(check_number(re) == '1')
	{
		alert("申请表编号后7位应为数字!");
		return -4;
	}
	return 1;
}

/********************************************************
16. 若认定编号项目为空,返回0;其他的不合法情况返回负值;如果合法返回1;
*********************************************************/
function _checkRdbh(rdbh)
{
	var val = rdbh;
	if(val.length==0)
		return 0;
	if(val.length!=12)
	{
		alert("认定编号应为12位!请检查您的输入");
		return -1;
	}

	var pre = val.substr(0, 4);
	var mid = val.substr(4, 1);
	var re  = val.substr(5, 7);

	if(check_number(pre) == '1')
	{
		alert("认定编号前4位应为数字!");
		return -2;
	}else if(check_c(mid) == '1')
	{
		alert("认定编号第5位应为字母!");
		return -3;
	}else if(check_number(re) == '1')
	{
		alert("认定编号后7位应为数字!");
		return -4;
	}
	return 1;
}

/**************************************************
17. 若工伤证号为空,返回0;其他的不合法情况返回负值;如果合法返回1;
*****************************************************/
function _checkGszh(gszh)
{
	var val = gszh;
	if(val.length==0)
		return 0;
	if(check_number_length(val, 8, -1)!=0 )
	{
		alert("工伤证号应为8位数字!请检查您的输入");
		return -1;
	}
	return 1;
}

/************************************************************************
18. 比较起始日期的合法性:start<=end ? 要求日期格式:yyyy.mm.dd or yyyy.m.d
//返回:如果两个日期有""的,返回0;如果第一个日期格式不合法,返回-1;
//如果第二个日期格式不合法,返回-2;如果第一个日期大于第二个日期,返回-3;
//如果第一个日期小于或者等于第二个日期,返回1;
************************************************************************/

function checkStartEndDate(startRQ, endRQ)
{
	if(startRQ.length <=0 && endRQ.length <= 0)
		return 0; //both length are 0;
    	if( startRQ.length > 0)
    	{//第一个不空
        	var msg = "";
		msg = check_date(startRQ,"D");
		if(trim(msg) != "")
		{
			//return(msg);
			return -1;//startRQ 有错
		}
		if(endRQ.length>0)
		{//第二个不空
			msg = check_date(endRQ,"D");
			if(trim(msg)!="")
			{
				//alert(msg);
				return -2;//endRQ 有错
			}
			//两个都不空,且都合法,
			var strs1 = startRQ.split(".");
			var strs2 = endRQ.split(".");
//alert(startRQ +"<="+ endRQ + "\n" + strs1[0]+"<"+strs2[0]+"\n"+strs1[1]+"<"+strs2[1]+"\n"+strs1[2]+"<"+strs2[2]);
//alert(startRQ +"<="+ endRQ + "\n" + parseInt(strs1[0], 10)+"<"+parseInt(strs2[0], 10)+"\n" + parseInt(strs1[1], 10)+"<"+parseInt(strs2[1], 10) + "\n"+ parseInt(strs1[2], 10)+"<"+parseInt(strs2[2], 10));
			if(parseInt(strs1[0], 10) < parseInt(strs2[0], 10))
				return 1;
			else if(parseInt(strs1[0], 10) == parseInt(strs2[0], 10))
			{	if(parseInt(strs1[1], 10) < parseInt(strs2[1], 10))
					return 1;
				else if(parseInt(strs1[1], 10) == parseInt(strs2[1], 10))
				{
					if(parseInt(strs1[2], 10) <= parseInt(strs2[2], 10))
						return 1;
					else
						return -3;//alert("查询开始日期不得大于结束日期!");
				}else
					return -3;
			}else //
				return -3;
		}else
			return 0;//第二个为空;
	}else //第一个为空,第二个不空
	{
		msg = check_date(endRQ,"D");
		if(trim(msg)!="")
		{
			//alert(msg);
			return -2;//endRQ 有错
		}
	}

	return 1;//两个不空,且都合法,且startRQ<=endRQ
}

/*****************************************************************************
19. 得到当前日期 格式:yyyy.mm.dd
*****************************************************************************/
function getCurDate()
{
	var today = new Date();
	var year = "";
	var month = "";
	var day = "";
	year = today.getYear() + "";
	month = (today.getMonth()+1) + "";
	day = today.getDate() + "";
	if(month.length<2)
		month = "0" + month;
	if(day.length<2)
		day = "0" + day;

	return year + "." + month + "." + day;
}


/*****************************************************************************
19. 求两个日期相差的天数:endRQ - startRQ。 输入参数格式:yyyy.mm.dd 或 yyyy.m.d
*****************************************************************************/
function diffDate(startRQ, endRQ)
{
	if(startRQ.length <=0)
		return ; //开始日期为空;
	if(endRQ.length <=0)
		return ; //结束日期为空;

	var	msg = check_date(startRQ,"D");
	if(trim(msg) != "")
	{
		//return(msg);
		return ;//startRQ 有错
	}
	msg = check_date(endRQ,"D");
	if(trim(msg)!="")
	{
		//alert(msg);
		return ;//endRQ 有错
	}

	var strs1 = startRQ.split(".");
	var strs2 = endRQ.split(".");

	var date1 = new Date(strs1[0], strs1[1], strs1[2]);
	var date2 = new Date(strs2[0], strs2[1], strs2[2]);
	var diffDay = (date2.getTime() + 0 - date1.getTime())/1000/60/60/24;	//days

	return diffDay;
}

⌨️ 快捷键说明

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