javascrip验证---validate.js

javascrip验证---validate.js

//??   2005-6-17  ????????
///////////////////////////////////////////////////////////////////////
//The follow jscript is used to validte the form fields       //
//                                                                   //
//Create By Geng Zhan                                                //
///////////////////////////////////////////////////////////////////////

//changed by yb 20050706 加入邮箱验证


//--------------------------------------------------------------------
//作用:校验Form中所有必填项是否为空,为空提示并返回焦点到相应域
//用法:结合CSS中定义的must样式,must样式将必填项的边框突出显示,在Form
//      提交时(onsubmit)调用此函数
//参数:无
//作者:耿战
//日起:2002-04-16
//--------------------------------------------------------------------
function checkEmpty(srcObj)
{
 var result=true;
 
 if (srcObj.value.length==0 || srcObj.value.length==srcObj.value.split(" ").length-1)
 {
  result=false;
  alert("输入项目["+srcObj.title+"]不能为空,请输入!");
  srcObj.focus();
 }
 return result; 
}
//--------------------------------------------------------------------
//作用:校验输入项中输入的是否为数字,不是数字弹出提示;
//用法:结合CSS中定义的num样式,num样式定义数字输入项的样式,在Form
//      提交时(onsubmit)调用此函数
//参数:无
//作者:耿战
//日起:2002-04-16
//--------------------------------------------------------------------
function checkNaN(srcObj)
{
 var result=true;
 
 if (isNaN(srcObj.value))
 {
  result=false;
  alert("输入项目["+srcObj.title+"]必须输入数字,请更改!");
  srcObj.focus();
 }
 return result; 
}

function checkRepeat(valueArray)
{
 var loop=valueArray.length;
// alert(loop);
 var refValue=valueArray[0];
 for (var i=1;i<loop;i++){
//   alert(valueArray.toString()+"+++"+refValue+":::"+valueArray[i]);
  if (valueArray[i]==refValue) {
   return false;
  }
  else
  {
   var newArray=valueArray.slice(i);
   if (checkRepeat(newArray)==false) return false;
  }
 }
 return true;
}

//--------------------------------------------------------------------
//作用:校验输入项中输入的是否为数字,不是数字弹出提示;
//用法:结合CSS中定义的num样式,num样式定义数字输入项的样式,在Form
//      提交时(onsubmit)调用此函数
//参数:无
//作者:耿战
//日起:2002-04-16
//--------------------------------------------------------------------
function checkPhone(srcObj)
{
 var result=true;
 var tempStr;
 
 tempStr=srcObj.value;
 while (tempStr.search("-")>=0)
 {
  tempStr=tempStr.replace("-","0");
 }
//  alert(tempStr);
 if (isNaN(tempStr) || (tempStr.length<6))
 {
  result=false;
  alert("输入项目["+srcObj.title+"]必须输入正确的电话号码,请更改!");
  srcObj.focus();
 }
 return result; 
}

//--------------------------------------------------------------------
//作用:校验日期输入项是否正确,不正确弹出提示;
//用法:结合CSS中定义的num样式,num样式定义数字输入项的样式,在Form
//      提交时(onsubmit)调用此函数
//参数:无
//作者:耿战
//日起:2002-04-16
//--------------------------------------------------------------------
function  checkDate(srcObj)
{
 var mini_year = 1900;
 var i_countSeparater = 0;
 var charset = "1234567890";
   
 var the_date = srcObj.value;
 var the_dateLength=the_date.length;
 var i_firstSepLoc = the_date.indexOf('-',0);
 var i_lastSepLoc = the_date.lastIndexOf('-');
 if (i_firstSepLoc < 0 || i_firstSepLoc == i_lastSepLoc)
 {
  alert('请输入“年-月-日”格式的正确时间!');
  return false;
 
 } 

 var the_year = the_date.substring(0,i_firstSepLoc);
 var the_month = the_date.substring(i_firstSepLoc+1,i_lastSepLoc);
 var the_day = the_date.substring(i_lastSepLoc+1,the_dateLength);
 if (! CheckChar(charset, the_year, true)){
     alert('年份应为数字!');
     return false;
 }

 if (! CheckChar(charset, the_month, true)){
     alert('月份应为数字!');
     return false;
 }
 if (! CheckChar(charset, the_day, true)){
     alert('日期应为数字!');
     return false;
 }

 if (the_year.length >4){
     alert('年份不能大于4位!');
     return false;
 }else if (the_year.length == 1){
     the_year = '200'+the_year;
 }else if (the_year.length == 2){
     the_year = '20'+the_year;
 }else if (the_year.length == 3){
     the_year = '2'+the_year;
 }else if (the_year.length == 0){
     alert('请输入“年-月-日”格式的正确时间!');
     return false;
 }   
   
 if (the_month.length > 2){
     alert('月份不能大于2位!');
     return false;
 }else if (the_month.length == 1){
     the_month = '0'+the_month;
 }else if (the_month.length ==0){
     alert('请输入由“-”分隔的正确的时间!');
     return false;
 } 

 if (the_day.length > 2){
     alert('日期不能大于2位!');
     return false;
 }else if (the_day.length == 1){
     the_day = '0'+the_day;
 }else if (the_day.length == 0){
     alert('请输入由“-”分隔的正确的时间!');
     return false;
 } 

    if ( the_year < mini_year){
        alert("年份不得小于 " + mini_year +"!");
        return false;
    }
    if (the_month < 01 || the_month > 12){
        alert("请输入正确的月份!")
        return false;
    }
    if (the_day >31 || the_day < 01){
        alert("请输入正确的日期!")
        return false;
       
    }else{
        switch(eval(the_month)) {
            case 4:
            case 6:
            case 9:
            case 11:
                if (the_day < 31){
                    the_date=the_year+'-'+the_month+'-'+the_day;
                    return the_date;
                }   
                break;
            case 2:
                var num = Math.floor(the_year/4) * 4;
                if(the_year == num) {
                    if (the_day < 30){
                        the_date=the_year+'-'+the_month+'-'+the_day;
                        return the_date;
                     }  
                } else {
                    if (the_day < 29){
                        the_date=the_year+'-'+the_month+'-'+the_day;
                        return the_date;
                    }   
                }
                break;
            default:
                if (the_day < 32){
                    the_date=the_year+'-'+the_month+'-'+the_day;
                    return the_date;
                }   
                break;
        }
    }
    alert("请输入正确的日期!");
    return false;
 
}


//--------------------------------------------------------------------
//作用:校验输入项是否有指定的字符;
//参数:charset:字符串;val:查找的字符;should_in:是否应该在串中
//作者:耿战
//日起:2002-04-16
//--------------------------------------------------------------------
function CheckChar(charset, val, should_in)
{
    var num = val.length;
    for (var i=0; i < num; i++) {
       var strchar = val.charAt(i);
       strchar = strchar.toUpperCase();
       if ((charset.indexOf(strchar) > -1) && (!should_in))
          return false;
       else if ((charset.indexOf(strchar) == -1) && (should_in))
          return false;
    }
    return true;
}
/***验证是否为电子邮箱***/
function validEmail(ele)
{
        if(!isEmail(ele.value))
        {
                alert("用户编号请输入有效邮箱");
                ele.focus();
                return false;
        }
        return true;
}
/***判断是否为邮箱***/
function isEmail(str)
{
        if(str.match(/[\w-.]+@{1}[\w-]+\.{1}\w{2,4}(\.{0,1}\w{2}){0,1}/ig)!=str)
                return false;
        else
                return true;
}
 
//--------------------------------------------------------------------
//作用:校验日期输入项是否正确,不正确弹出提示;
//用法:结合CSS中定义的num样式,num样式定义数字输入项的样式,在Form
//      提交时(onsubmit)调用此函数
//参数:无
//作者:耿战
//日起:2002-04-16
//--------------------------------------------------------------------

function formValidation()
{
 var formObj=window.event.srcElement;
 var len=formObj.elements.length;
 var i;
 var srcObj;
 
 for (i=0;i<len;i++)
 {
  srcObj=formObj.elements[i]; 
  if (srcObj.tagName=="INPUT" && (srcObj.type=="text"||srcObj.type=="password") || srcObj.tagName=="SELECT")
  {
   switch (srcObj.className)
   {
    case 'must':
     if (checkEmpty(srcObj)==false) return false;
     break;
    case 'usermust':
      if (checkEmpty(srcObj)==false) return false;
     if (validEmail(srcObj)==false) return false;
     break;
    case 'number-must':
     if (checkEmpty(srcObj)==false) return false;
     if (checkNaN(srcObj)==false) return false;
     break;
    case 'date-must':
     if (checkEmpty(srcObj)==false) return false;
     if (checkDate(srcObj)==false) return false;
     break;
    case 'number':
     if (srcObj.value.length>0)
     {
      if (checkNaN(srcObj)==false) return false;
     }
     break;
    case 'date':
     if (srcObj.value.length>0)
     {
      if (checkDate(srcObj)==false) return false;
     }
     break;
    case 'phone-must':
     if (checkPhone(srcObj)==false) return false;
     break;
    case 'phone':
     if (srcObj.value.length>0)
     {
      if (checkPhone(srcObj)==false) return false;
     }
     break;
   }
  }
 }
 return true;
}

//--------------------------------------------------------------------
//作用:校验日期输入项是否正确,不正确弹出提示;
//用法:结合CSS中定义的num样式,num样式定义数字输入项的样式,在Form
//      提交时(onsubmit)调用此函数
//参数:无
//作者:耿战
//日起:2002-04-16
//--------------------------------------------------------------------

function formValidationById(formId)
{
 var formObj=document.getElementById(formId);
// alert("111:"+formObj);
 if (!formObj){
  formObj=document.forms[formId];
//  alert(formObj.tagName)
 }
// alert("112:"+formObj);
 if (!formObj) formObj=eval("document.all."+formId);
// alert("113:"+formObj);
 if (!formObj) formObj=document.all.item(formId);
// alert("114:"+formObj);
 var len=formObj.elements.length;
 var i;
 var srcObj;
 
 for (i=0;i<len;i++)
 {
  srcObj=formObj.elements[i]; 
  if (srcObj.tagName=="INPUT" && srcObj.type=="text" || srcObj.tagName=="SELECT")
  {
   switch (srcObj.className)
   {
    case 'must':
     if (checkEmpty(srcObj)==false) return false;
     break;
    case 'number-must':
     if (checkEmpty(srcObj)==false) return false;
     if (checkNaN(srcObj)==false) return false;
     break;
    case 'date-must':
     if (checkEmpty(srcObj)==false) return false;
     if (checkDate(srcObj)==false) return false;
     break;
    case 'number':
     if (srcObj.value.length>0)
     {
      if (checkNaN(srcObj)==false) return false;
     }
     break;
    case 'date':
     if (srcObj.value.length>0)
     {
      if (checkDate(srcObj)==false) return false;
     }
     break;
    case 'phone-must':
     if (checkPhone(srcObj)==false) return false;
     break;
    case 'phone':
     if (srcObj.value.length>0)
     {
      if (checkPhone(srcObj)==false) return false;
     }
     break;
   }
  }
 }
 return true;
}

function readOnlyAll()
{
 var loop=document.forms.length
 var Ele;
 for (var i=0;i<loop;i++)
 {
  for( var j=0;j<document.forms[i].elements.length;j++)
  {
   Ele=document.forms[i].elements[j];
   switch(Ele.tagName)
   {
    case 'INPUT':
     if ((Ele.type=="button" || Ele.type=="submit" ||Ele.type=="reset") && Ele.className!='SHOWALWAYS' ){
      Ele.className="off";
      Ele.disabled=true;
     }
     else
     {
      if(Ele.type=="radio" || Ele.type=="checkbox") Ele.disabled=true;
      else Ele.readOnly=true;
     }
     break;
     
    case 'SELECT':
     Ele.className="off";
     Ele.insertAdjacentText('beforeBegin',Ele.value);
     break;
     
    case 'TEXTAREA':
     Ele.readOnly=true;
     break;
   }
  }
 }
}

 

var refString="must,number,date,phone,number-must,date-must,phone-must";
function hideCheck(padObj)
{
 if (padObj){
  if (padObj.tagName=='DIV'){
   var len=padObj.all.length;
   for(var i=0;i<len;i++){
    var item=padObj.all.item(i);
    if (refString.search(item.className.toLowerCase())>-1){
     item.className="hidden-"+item.className;
    }
   }
  }
 }
}

function showCheck(padObj)
{
 if (padObj){
  if (padObj.tagName=='DIV'){
   var len=padObj.all.length;
   for(var i=0;i<len;i++){
    var item=padObj.all.item(i);
//    alert(item.className.search("hidden-")+":::"+item.className.slice(7));
    if (item.className.search("hidden-")> -1) item.className=item.className.slice(7);
   }
  }
 }
}
//--------------------------------------------------------------------
//作用:以下4个函数是数值型变量的小数位处理函数,分别为:
// fixNumber: 四舍五入;
// greaterNumber: 取大值;
// lessNumber: 取小值;
// halfFixNumber: 先四舍五入,结果最后一位不足5按5计算,最后一位大于五进位;
//用法:fixNumber(0.626,2)=0.63 fixNumber(0.23,1)=0.2
// greaterNumber(0.626,2)=0.63 greaterNumber(0.23,1)=0.3
// lessNumber(0.626,2)=0.62 lessNumber(0.23,1)=0.2
// halfFixNumber(0.626,2)=0.65 halfFixNumber(0.23,1)=0.5
//参数:orgNumber:原始数值,可以为字符或数字型;
// fractions:返回的小数位数;
//返回值:字符串
//作者:耿战
//日起:2002-04-16
//--------------------------------------------------------------------
function fixNumber(orgNumber,fractions)
{
 if (isNaN(orgNumber)) return 'NaN';
 
 var tempValue=parseFloat(orgNumber);
 var rtValue=tempValue.toFixed(parseInt(fractions)); 
 return rtValue;
}
function greaterNumber(orgNumber,fractions)
{
 if (isNaN(orgNumber)) return 'NaN';
 
 var tempValue=parseFloat(orgNumber);
 var rtValue=tempValue.toFixed(parseInt(fractions));
 if (parseFloat(rtValue)<tempValue){
  rtValue=((parseFloat(rtValue)*Math.pow(10,parseInt(fractions))+1)/Math.pow(10,parseInt(fractions))).toFixed(parseInt(fractions));
 } 
 return rtValue;
}
function lessNumber(orgNumber,fractions)
{
 if (isNaN(orgNumber)) return 'NaN';
 
 var tempValue=parseFloat(orgNumber);
 var rtValue=tempValue.toFixed(parseInt(fractions));
 if (parseFloat(rtValue)>tempValue){
  rtValue=((parseFloat(rtValue)*Math.pow(10,parseInt(fractions))-1)/Math.pow(10,parseInt(fractions))).toFixed(parseInt(fractions));
 } 
 return rtValue;
}
function halfFixNumber(orgNumber,fractions)
{
 if (isNaN(orgNumber)) return 'NaN';
 
 var tempValue=parseFloat(orgNumber);
 var rtValue=tempValue.toFixed(parseInt(fractions));
 if (parseInt(rtValue.substr(rtValue.length-1,1))<5 && parseInt(rtValue.substr(rtValue.length-1,1))>0){
  rtValue=rtValue.substr(0,rtValue.length-1)+'5'; 
 }
 if (parseInt(rtValue.substr(rtValue.length-1,1))>5 && parseInt(rtValue.substr(rtValue.length-1,1))<=9){
  rtValue=greaterNumber(rtValue,parseInt(fractions)-1)+'0'; 
 }
 return rtValue;
}

function find()
{ var objTableLeft=document.getElementById('item_list');
 var Rows=objTableLeft.rows.length;
 var intSelectNum = 0;
  
 for( var i=2;i<Rows;i++)
 {
  if(objTableLeft.rows[i].cells[0].children[0].checked)
  {
   intSelectNum++;
   strProject_ID = objTableLeft.rows[i].cells[0].children[0].value;
   break;
  } 
 }
 return intSelectNum; 
// if(intSelectNum!=1){
//  return false;
// }else return true;
}

function checkAll(){
 var nn=document.forms[0].elements.length;
 
 for(var i=0;i<nn;i++){
  var v=document.forms[0].elements[i].name;
  if(v=="del_uid"){
   document.forms[0].elements[i].checked=true;
  }
 }
}

function unCheckAll(){
 var nn=document.forms[0].elements.length;
 for(var i=0;i<nn;i++){
  var v=document.forms[0].elements[i].name;
  if(v=="del_uid"){
   document.forms[0].elements[i].checked=false;
  }
 }
}

//--------------------------------------------------------------------
//????????????
//changed by an 2005-06-17
//--------------------------------------------------------------------
function PopupCalendar(InstanceName)
{
 ///Global Tag
 this.instanceName=InstanceName;
 ///Properties
 this.separator="-"
 this.oBtnTodayTitle="Today"
 this.oBtnCancelTitle="Cancel"
 this.weekDaySting=new Array("S","M","T","W","T","F","S");
 this.monthSting=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
 this.Width=200;
 this.currDate=new Date();
 this.today=new Date();
 this.startYear=1970;
 this.endYear=2020;
 ///Css
 this.divBorderCss="1px solid #BCD0DE";
 this.tableBorderColor="#CCCCCC"
 ///Method
 this.Init=CalendarInit;
 this.Fill=CalendarFill;
 this.Refresh=CalendarRefresh;
 this.Restore=CalendarRestore;
 ///HTMLObject
 this.oTaget=null;
 this.oPreviousCell=null;
 this.sDIVID=InstanceName+"oDiv";
 this.sTABLEID=InstanceName+"oTable";
 this.sMONTHID=InstanceName+"oMonth";
 this.sYEARID=InstanceName+"oYear";
 
}
function CalendarInit()    ///Create panel
{
 var sMonth,sYear
 sMonth=this.currDate.getMonth();
 sYear=this.currDate.getYear();
 htmlAll="<div id='"+this.sDIVID+"' style='display:none;position:absolute;width:130;border:"+this.divBorderCss+";padding:1px;background-color:#FFFFFF;z-index:100';>";
 //htmlAll+="<div align='center'>";
 /// Month
 htmloMonth="<select id='"+this.sMONTHID+"' onchange=CalendarMonthChange("+this.instanceName+") style='width:50%;background-color:#D0F5FF;'>";
 for(i=0;i<12;i++)
 {   
  htmloMonth+="<option value='"+i+"'>"+this.monthSting[i]+"</option>";
 }
 htmloMonth+="</select>";
 /// Year
 htmloYear="<select id='"+this.sYEARID+"' onchange=CalendarYearChange("+this.instanceName+") style='width:50%;background-color:#D0F5FF;'>";
 for(i=this.startYear;i<=this.endYear;i++)
 {
  htmloYear+="<option value='"+i+"'>"+i+"</option>";
 }
 htmloYear+="</select>";
 /// Day
 htmloDayTable="<table id='"+this.sTABLEID+"' width='130' border=0 cellpadding=0 cellspacing=1 bgcolor='"+this.tableBorderColor+"'>";
 htmloDayTable+="<tbody bgcolor='#ffffff'style='font-size:10px;'>";
 for(i=0;i<=6;i++)
 {
  if(i==0)
   htmloDayTable+="<tr bgcolor='#98B8CD'>";
  else
   htmloDayTable+="<tr>";
  for(j=0;j<7;j++)
  {

   if(i==0)
   {
    htmloDayTable+="<td height='14' align='center' valign='middle' style='cursor:hand;font-size:12px;'>";
    htmloDayTable+=this.weekDaySting[j]+"</td>"
   }
   else
   {
    htmloDayTable+="<td height='14' align='center' valign='middle' style='cursor:hand;font-size:12px;'";
    htmloDayTable+=" onmouseover=CalendarCellsMsOver("+this.instanceName+")";
    htmloDayTable+=" onmouseout=CalendarCellsMsOut("+this.instanceName+")";
    htmloDayTable+=" onclick=CalendarCellsClick(this,"+this.instanceName+")>";
    htmloDayTable+="&nbsp;</td>"
   }
  }
  htmloDayTable+="</tr>"; 
 }
 htmloDayTable+="</tbody></table>";
 /// Today Button
 htmloButton="<div align='center' style='padding:1px'>"
 htmloButton+="<button style='width:40px;height:16px;border:1px solid #BCD0DE;background-color:#eeeeee;cursor:hand;font-size:12px;'"
 htmloButton+=" onclick=CalendarTodayClick("+this.instanceName+")>"+this.oBtnTodayTitle+"</button>&nbsp;"
 htmloButton+="<button style='width:40px;height:16px;border:1px solid #BCD0DE;background-color:#eeeeee;cursor:hand;font-size:12px;'"
 htmloButton+=" onclick=CalendarCancel("+this.instanceName+")>"+this.oBtnCancelTitle+"</button> "
 htmloButton+="</div>"
 /// All
 htmlAll=htmlAll+htmloYear+htmloMonth+htmloDayTable+htmloButton+"</div>";
 document.write(htmlAll);
 this.Fill(); 
}
function CalendarFill()   ///
{
 var sMonth,sYear,sWeekDay,sToday,oTable,currRow,MaxDay,sDaySn,sIndex,rowIndex,cellIndex,oSelectMonth,oSelectYear
 sMonth=this.currDate.getMonth();
 sYear=this.currDate.getYear();
 sWeekDay=(new Date(sYear,sMonth,1)).getDay();
 sToday=this.currDate.getDate();
 oTable=document.all[this.sTABLEID];
 currRow=oTable.rows[1];
 MaxDay=CalendarGetMaxDay(sYear,sMonth);
 
 oSelectMonth=document.all[this.sMONTHID]
 oSelectMonth.selectedIndex=sMonth;
 oSelectYear=document.all[this.sYEARID]
 for(i=0;i<oSelectYear.length;i++)
 {
  if(parseInt(oSelectYear.options[i].value)==sYear)oSelectYear.selectedIndex=i;
 }
 ////
 for(sDaySn=1,sIndex=sWeekDay;sIndex<=6;sDaySn++,sIndex++)
 {

  if(sDaySn==sToday)
  {
   currRow.cells[sIndex].innerHTML="<font color=red><i><b>"+sDaySn+"</b></i></font>";
   this.oPreviousCell=currRow.cells[sIndex];
  }
  else
  {
   currRow.cells[sIndex].innerHTML=sDaySn;
   currRow.cells[sIndex].style.color="#666666"; 
  }
  CalendarCellSetCss(0,currRow.cells[sIndex]);
 }
 for(rowIndex=2;rowIndex<=6;rowIndex++)
 {
  if(sDaySn>MaxDay)break;
  currRow=oTable.rows[rowIndex];
  for(cellIndex=0;cellIndex<currRow.cells.length;cellIndex++)
  {
   if(sDaySn==sToday)
   {
    currRow.cells[cellIndex].innerHTML="<font color=red><i><b>"+sDaySn+"</b></i></font>";
    this.oPreviousCell=currRow.cells[cellIndex];
   }
   else
   {
    currRow.cells[cellIndex].innerHTML=sDaySn; 
    currRow.cells[cellIndex].style.color="#666666"; 
   }
   CalendarCellSetCss(0,currRow.cells[cellIndex]);
   sDaySn++;
   if(sDaySn>MaxDay)break; 
  }
 }
}
function CalendarRestore()     /// Clear Data

 var oTable
 oTable=document.all[this.sTABLEID]
 for(i=1;i<oTable.rows.length;i++)
 {
  for(j=0;j<oTable.rows[i].cells.length;j++)
  {
   CalendarCellSetCss(0,oTable.rows[i].cells[j]);
   oTable.rows[i].cells[j].innerHTML="&nbsp;";
  }
 } 
}
function CalendarRefresh(newDate)     ///
{
 this.currDate=newDate;
 this.Restore(); 
 this.Fill(); 
}
function CalendarCellsMsOver(oInstance)    /// Cell MouseOver
{
 var myCell
 myCell=event.srcElement;
 CalendarCellSetCss(0,oInstance.oPreviousCell);
 if(myCell)
 {
  CalendarCellSetCss(1,myCell);
  oInstance.oPreviousCell=myCell;
 }
}
function CalendarCellsMsOut(oInstance)    ////// Cell MouseOut
{
 var myCell
 myCell=event.srcElement;
 CalendarCellSetCss(0,myCell); 
}
function CalendarCellsClick(oCell,oInstance)
{
 var sDay,sMonth,sYear,newDate
 sYear=oInstance.currDate.getFullYear();
 sMonth=oInstance.currDate.getMonth();
 sDay=oInstance.currDate.getDate();
 if(oCell.innerText!=" ")
 {
  sDay=parseInt(oCell.innerText);
  if(sDay!=oInstance.currDate.getDate())
  {
   newDate=new Date(sYear,sMonth,sDay);
   oInstance.Refresh(newDate);
  }
 }
 sDateString=sYear+oInstance.separator+CalendarDblNum(sMonth+1)+oInstance.separator+CalendarDblNum(sDay);  ///return sDateString
 if(oInstance.oTaget.tagName=="INPUT")
 {
  oInstance.oTaget.value=sDateString;
 }
 document.all[oInstance.sDIVID].style.display="none";  
}
function CalendarYearChange(oInstance)    /// Year Change
{
 var sDay,sMonth,sYear,newDate
 sDay=oInstance.currDate.getDate();
 sMonth=oInstance.currDate.getMonth();
 sYear=document.all[oInstance.sYEARID].value
 newDate=new Date(sYear,sMonth,sDay);
 oInstance.Refresh(newDate);
}
function CalendarMonthChange(oInstance)    /// Month Change
{
 var sDay,sMonth,sYear,newDate
 sDay=oInstance.currDate.getDate();
 sMonth=document.all[oInstance.sMONTHID].value
 sYear=oInstance.currDate.getYear();
 newDate=new Date(sYear,sMonth,sDay);
 oInstance.Refresh(newDate); 
}
function CalendarTodayClick(oInstance)    /// "Today" button Change

 oInstance.Refresh(new Date());  
}
function getDateString(oInputSrc,oInstance)
{
 if(oInputSrc&&oInstance)
 {
  CalendarDiv=document.all[oInstance.sDIVID];
  oInstance.oTaget=oInputSrc;
  CalendarDiv.style.pixelLeft=CalendargetPos(oInputSrc,"Left")-134+oInputSrc.offsetWidth;
  CalendarDiv.style.pixelTop=CalendargetPos(oInputSrc,"Top")+oInputSrc.offsetHeight;
  CalendarDiv.style.display=(CalendarDiv.style.display=="none")?"":"none";
 } 
}
function CalendarCellSetCss(sMode,oCell)   /// Set Cell Css
{
 // sMode
 // 0: OnMouserOut 1: OnMouseOver
 if(sMode)
 {
  oCell.style.border="1px solid #5589AA";
  oCell.style.backgroundColor="#BCD0DE";
 }
 else
 {
  oCell.style.border="1px solid #FFFFFF";
  oCell.style.backgroundColor="#FFFFFF";
 } 
}
function CalendarGetMaxDay(nowYear,nowMonth)   /// Get MaxDay of current month
{
 var nextMonth,nextYear,currDate,nextDate,theMaxDay
 nextMonth=nowMonth+1;
 if(nextMonth>11)
 {
  nextYear=nowYear+1;
  nextMonth=0;
 }
 else 
 {
  nextYear=nowYear; 
 }
 currDate=new Date(nowYear,nowMonth,1);
 nextDate=new Date(nextYear,nextMonth,1);
 theMaxDay=(nextDate-currDate)/(24*60*60*1000);
 return theMaxDay;
}
function CalendargetPos(el,ePro)    /// Get Absolute Position
{
 var ePos=0;
 while(el!=null)
 {  
  ePos+=el["offset"+ePro];
  el=el.offsetParent;
 }
 return ePos;
}
function CalendarDblNum(num)
{
 if(num<10)
  return "0"+num;
 else
  return num;
}
function CalendarCancel(oInstance)   ///Cancel
{
 CalendarDiv=document.all[oInstance.sDIVID];
 CalendarDiv.style.display="none";  
}
//?????
  function tyse()
  { 
  var A_checked = window.document.queryFrm.typeselectA.checked;
  var B_checked = window.document.queryFrm.typeselectB.checked;
  var C_checked = window.document.queryFrm.typeselectC.checked;
  var D_checked = window.document.queryFrm.typeselectD.checked; 
  var E_checked = window.document.queryFrm.typeselectE.checked;
  var F_checked = window.document.queryFrm.typeselectF.checked;
  var G_checked = window.document.queryFrm.typeselectG.checked;
  var H_checked = window.document.queryFrm.typeselectH.checked;
  var I_checked = window.document.queryFrm.typeselectI.checked;
  var J_checked = window.document.queryFrm.typeselectJ.checked;
  var K_checked = window.document.queryFrm.typeselectK.checked;
  var N_checked = window.document.queryFrm.typeselectN.checked; 
  var P_checked = window.document.queryFrm.typeselectP.checked;
  var Q_checked = window.document.queryFrm.typeselectQ.checked;
  var R_checked = window.document.queryFrm.typeselectR.checked;
  var S_checked = window.document.queryFrm.typeselectS.checked; 
  var U_checked = window.document.queryFrm.typeselectU.checked;
  var V_checked = window.document.queryFrm.typeselectV.checked;
  var X_checked = window.document.queryFrm.typeselectX.checked;
  var Z_checked = window.document.queryFrm.typeselectZ.checked;   
  var num1_checked = window.document.queryFrm.typeselect01.checked;
  var num2_checked = window.document.queryFrm.typeselect02.checked;
  var num3_checked = window.document.queryFrm.typeselect03.checked;
  var num4_checked = window.document.queryFrm.typeselect04.checked; 
  var num5_checked = window.document.queryFrm.typeselect05.checked;
  var num6_checked = window.document.queryFrm.typeselect06.checked;
  var num7_checked = window.document.queryFrm.typeselect07.checked;
  var TB_checked = window.document.queryFrm.typeselectTB.checked;
  var TE_checked = window.document.queryFrm.typeselectTE.checked;
  var TD_checked = window.document.queryFrm.typeselectTD.checked;
  var TF_checked = window.document.queryFrm.typeselectTF.checked;
  var TH_checked = window.document.queryFrm.typeselectTH.checked; 
  var TJ_checked = window.document.queryFrm.typeselectTJ.checked;
  var TK_checked = window.document.queryFrm.typeselectTK.checked;
  var TL_checked = window.document.queryFrm.typeselectTL.checked;
  var TM_checked = window.document.queryFrm.typeselectTM.checked; 
  var TX_checked = window.document.queryFrm.typeselectTX.checked;
  var TP_checked = window.document.queryFrm.typeselectTP.checked;
  var TQ_checked = window.document.queryFrm.typeselectTQ.checked;
  var TS_checked = window.document.queryFrm.typeselectTS.checked;
  var TU_checked = window.document.queryFrm.typeselectTU.checked;   
  var TV_checked = window.document.queryFrm.typeselectTV.checked;                       
  if(A_checked==true)
  { A=",'A'";}
  else
  {A="";}
  if(B_checked==true)
  {B=",'B'"; }
  else
  {B="";}
  if(C_checked==true)
  {C=",'C'"; }
  else
  {C="";}
  if(D_checked==true)
  { D=",'D'";}
  else
  {D="";}
  if(E_checked==true)
  { E=",'E'";}
  else
  {E="";}
  if(F_checked==true)
  {F=",'F'"; }
  else
  {F="";}
  if(G_checked==true)
  {G=",'G'"; }
  else
  {G="";}
  if(H_checked==true)
  { H=",'H'";}
  else
  {H="";}
  if(I_checked==true)
  { I=",'I'";}
  else
  {I="";}
  if(J_checked==true)
  {J=",'J'"; }
  else
  {J="";}
  if(K_checked==true)
  {K=",'K'"; }
  else
  {K="";}
  if(N_checked==true)
  { N=",'N'";}
  else
  {N="";}
  if(P_checked==true)
  { P=",'P'";}
  else
  {P="";}
  if(Q_checked==true)
  {Q=",'Q'"; }
  else
  {Q="";}
  if(R_checked==true)
  {R=",'R'"; }
  else
  {R="";}
  if(S_checked==true)
  { S=",'S'";}
  else
  {S="";} 
 if(U_checked==true)
  { U=",'U'";}
  else
  {U="";}
  if(V_checked==true)
  {V=",'V'"; }
  else
  {V="";}
  if(X_checked==true)
  {X=",'X'"; }
  else
  {X="";}
  if(Z_checked==true)
  { Z=",'Z'";}
  else
  {Z="";}
 
 
  if(num1_checked==true)
  { num1=",'01'";}
  else


  {num1="";}
  if(num2_checked==true)
  {num2=",'02'"; }
  else
  {num2="";}
  if(num3_checked==true)
  {num3=",'03'"; }
  else
  {num3="";}
  if(num4_checked==true)
  { num4=",'04'";}
  else
  {num4="";}
  if(num5_checked==true)
  { num5=",'05'";}
  else
  {num5="";}
  if(num6_checked==true)
  {num6=",'06'"; }
  else
  {num6="";}
  if(num7_checked==true)
  {num7=",'07'"; }
  else
  {num7="";}
  if(TB_checked==true)
  { TB=",'TB'";}
  else
  {TB="";}
  if(TE_checked==true)
  { TE=",'TE'";}
  else
  {TE="";}
  if(TD_checked==true)
  {TD=",'TD'"; }
  else
  {TD="";}
  if(TF_checked==true)
  {TF=",'TF'"; }
  else
  {TF="";}
  if(TH_checked==true)
  { TH=",'TH'";}
  else
  {TH="";}
  if(TJ_checked==true)
  { TJ=",'TJ'";}
  else
  {TJ="";}
  if(TK_checked==true)
  {TK=",'TK'"; }
  else
  {TK="";}
  if(TL_checked==true)
  {TL=",'TL'"; }
  else
  {TL="";}
  if(TM_checked==true)
  { TM=",'TM'";}
  else
  {TM="";} 
 if(TX_checked==true)
  { TX=",'TX'";}
  else
  {TX="";}
  if(TP_checked==true)
  {TP=",'TP'"; }
  else
  {TP="";}
  if(TQ_checked==true)
  {TQ=",'TQ'"; }
  else
  {TQ="";}
  if(TS_checked==true)
  { TS=",'TS'";}
  else
  {TS="";}
  if(TU_checked==true)
  { TU=",'TU'";}
  else
  {TU="";}
  if(TV_checked==true)
  { TV=",'TV'";}
  else
  {TV="";}                      
  document.queryFrm.typetxt.value="''"+A+B+C+D+E+F+G+H+I+J+K+N+P+Q+R+S+U+V+X+Z+num1+num2+num3+num4+num5+num6+num7+TB+TE+TD+TF+TH+TJ+TK+TL+TM+TX+TP+TQ+TS+TU+TV;
  queryFrm.submit();
  }

//-->

你可能感兴趣的:(javascrip验证---validate.js)