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

📄 javascript.js

📁 gensou.rar为某渔具厂的一个简单ERP系统。为比较基础的工程
💻 JS
字号:

/*用于将数字转换成字符串,并载取小数位数*/
function numberToStr(number){
   s=number.toString();
   i=s.indexOf('.');

   if(i==-1){
     result=s+'.00';
   }
   else{
   m=s.charAt(i+2);

   n=s.charAt(i+3);
   var result=s.substring(0,i+3);
   if(m==''){
      if(n==''){
      result=result+'0';
      }else{
      result=result+'00';
      }
   }
   
   
 }
   return result;
}
function printpdf(basepath,url){
	//alert(url);
	//alert(basepath);
	//var obj_lookupwindow = window.open(view_name + sep + 'id=' + this.id + argString,'FieldLookup', 'width=300,height=300,scrollbars=yes,status=no,resizable=yes,top='+my+',left='+mx+',dependent=yes,alwaysRaised=yes');
	realurl=encodeURI(url);
	var realurl=basepath+'Market/control/createPdf?targetUrl='+url;
	
	
	//alert(realurl);
	//alert(realurl);
	window.open(realurl,'null','width=300,height=250,scrollbars=yes,status=yes,resizable=yes,top=0,left=0,dependent=yes,alwaysRaised=yes');
	}
function posURI(groupID)
{

groupIDEncoder=encodeURI(groupID);
location.href=groupIDEncoder;
//alert(groupIDEncoder);
}
///////////////////////////////////////////
function getStringLength(str){
  var endvalue=0;
  var sourcestr=new String(str);
  var tempstr;
  for (var strposition = 0; strposition < sourcestr.length; strposition ++) {
    tempstr=sourcestr.charAt(strposition);
    if (tempstr.charCodeAt(0)>255 || tempstr.charCodeAt(0)<0) {
      endvalue=endvalue+2;
    } else {
      endvalue=endvalue+1;
    }
  }
  return(endvalue);
}
function trim(str){
  if(str==null) return "";
  if(str.length==0) return "";
  var i=0,j=str.length-1,c;
  for(;i<str.length;i++){
    c=str.charAt(i);
    if(c!=' ') break;
  }
  for(;j>-1;j--){
    c=str.charAt(j);
    if(c!=' ') break;
  }
  if(i>j) return "";
  return str.substring(i,j+1); 
}
function validateDate(date,format,alt){
  var time=trim(date.value);
 
  if(time=="") return;
  var reg=format;
  var reg=reg.replace(/yyyy/,"[0-9]{4}");
  var reg=reg.replace(/yy/,"[0-9]{2}");
  var reg=reg.replace(/MM/,"((0[1-9])|1[0-2])");
  var reg=reg.replace(/M/,"(([1-9])|1[0-2])");
  var reg=reg.replace(/dd/,"((0[1-9])|([1-2][0-9])|30|31)");
  var reg=reg.replace(/d/,"([1-9]|[1-2][0-9]|30|31))");
  var reg=reg.replace(/HH/,"(([0-1][0-9])|20|21|22|23)");
  var reg=reg.replace(/H/,"([0-9]|1[0-9]|20|21|22|23)");
  var reg=reg.replace(/mm/,"([0-5][0-9])");
  var reg=reg.replace(/m/,"([0-9]|([1-5][0-9]))");
  var reg=reg.replace(/ss/,"([0-5][0-9])");
  var reg=reg.replace(/s/,"([0-9]|([1-5][0-9]))");
  reg=new RegExp("^"+reg+"$");
  if(reg.test(time)==false){//????????????????
    alert(alt);
    date.focus();
    return false;
  }
  return true;
}
function validateDateGroup(year,month,day,alt){
  var array=new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  var y=parseInt(year.value);
  var m=parseInt(month.value);
  var d=parseInt(day.value);
  var maxday=array[m-1];
  if(m==2){
    if((y%4==0&&y%100!=0)||y%400==0){
      maxday=29;
    }
  }
  if(d>maxday){
    alert(alt);
    return false;
  }
  return true;
}
function validateCheckbox(obj,alt){
  var rs=false;
  if(obj!=null){
    if(obj.length==null){
      return obj.checked;
    }
    for(i=0;i<obj.length;i++){
      if(obj[i].checked==true){
        return true;
      }
    }
  }
  alert(alt);
  return rs;
}
function validateRadio(obj,alt){
  var rs=false;
  if(obj!=null){
    if(obj.length==null){
      return obj.checked;
    }
    for(i=0;i<obj.length;i++){
      if(obj[i].checked==true){
        return true;
      }
    }
  }
  alert(alt);
  return rs;
}
function validateSelect(obj,alt){
  var rs=false;
  if(obj!=null){
    for(i=0;i<obj.options.length;i++){
      if(obj.options[i].selected==true){
        return true;
      }
    }
  }
  alert(alt);
  return rs;
}
function validateEmail(email,alt,separator){
  var mail=trim(email.value);
  if(mail=="") return;
  var em;
  var myReg = /^[_a-z0-9]+@([_a-z0-9]+\.)+[a-z0-9]{2,3}$/;
  if(separator==null){
    if(myReg.test(email.value)==false){
      alert(alt);
      email.focus();
      return false;
    }
  }
  else{
    em=email.value.split(separator);
    for(i=0;i<em.length;i++){
      em[i]=em[i].trim();
      if(em[i].length>0&&myReg.test(em[i])==false){
        alert(alt);
        email.focus();
        return false;
      }
    }
  }
  return true;
}

function isnumber(str)
{
var number_chars = "1234567890";
var i;
for (i=0;i<str.length;i++)
{
if (number_chars.indexOf(str.charAt(i))==-1) return false;
}
return true;
}
/*Check Date biger*/
function checkDate(strNum1,strNum2){
   
   
   var f=isnumber(strNum1);
   if(f==false){
     alert('交提货数量应为数字!');
     return false;
   }else{
  var num1=parseInt(strNum1);
  var num2=parseInt(strNum2);

   if(num2<num1){
     alert('交提货数量必须小于购买数量');
   
     return false;
     }
   }

    return true;
   
}
/*This code is used by programmer of Shiyan and other programers don't use it*/
  
function totalSum(){
       var strNum=document.form1.amount.value;
       num=parseInt(strNum);
       price=document.form1.price.value;
       if(price.indexOf('¥')>-1){
			
			var result=price.replace('¥','');
			if(result.indexOf(',')>-1){
				result=result.replace(',','');
				//alert(result);
			   }
			}
			
			else{
			   result=parseInt(price);
			}
			var showSubTotal=numberToStr(num*result);
			//alert(showSubTotal);
            document.form1.subtotal.value=showSubTotal;
}
function goNext(check1,check2){
    
   
   if(check1==true&& check2==true)
   {
   totalSum();
   return true;
   }
   else{
   //alert('您的添加内容有错误');
   return false;
   }
}
function goNext2(check1,check2){
    
   
   if(check1==true&& check2==true)
   {
   //totalSum();
   return true;
   }
   else{
   //alert('您的添加内容有错误');
   return false;
   }
}
/*The function is used for getting a value of two input'product*/
function formTotal(amount,id1,id2,id3){
			//alert(id1);
			//var objtemp=document.getElementById(id1);
			//alert(objtemp);
			document.getElementById(id3).value=amount.value;
			var strPrice=document.getElementById(id1).value;
		
			if(strPrice.indexOf('¥')>-1){
			
			var result=strPrice.replace('¥','');
			if(result.indexOf(',')>-1){
				result=result.replace(',','');
				result=parseFloat(result);
			
			   }
			}
			
			else{
			   result=parseFloat(strPrice);
			}
			var strNum=parseInt(amount.value);
		    var t=isnumber(strNum);
		    if(t==false){
		      alert('您应输入数字!');
		      num.focus();
		      return false
		    }
		    rr=numberToStr(result*strNum);
			document.getElementById(id2).value="¥"+rr;//tie
		
			}
function validateForm(theForm){// ????????????????true
  var disableList=new Array();
  var field = theForm.elements; // ??????????????????????????
  for(var i = 0; i < field.length; i++){
    var vali=theForm.validate;
 if(vali!=null){
   if(vali.value=="0"){
     var fun=vali.functionName;
  if(fun!=null){
    return eval(fun+"()");
  }
  else{
    return true;
  }
   }
 }



    var empty=false;
    var value=trim(field[i].value);
    if(value.length==0){//????????
      empty=true;
    }
    var emptyInfo=field[i].emptyInfo;//????????//??????emptyInfo??253????emptyInfo(????????????)??????????form??????????
    if(emptyInfo!=null&&empty==true){
      alert(emptyInfo);
      field[i].focus();
      return false;
    }
    var lengthInfo=field[i].lengthInfo;//???????????? 
    if(lengthInfo!=null&&getStringLength(value)>field[i].maxLength){
      alert(lengthInfo);
      field[i].focus();
      return false;
    }



    var validatorType=field[i].validatorType;
    if(validatorType!=null){//????javascript
      var rs=true;
      if(validatorType=="javascript"){
        eval("rs="+field[i].functionName+"()");
        if(rs==false){
          return false;
        }
        else{
          continue;
        }
      }
      else if(validatorType=="disable"){//??????????disable??????
        disableList.length++;
        disableList[disableList.length-1]=field[i];
        continue;
      }
      else if(validatorType=="Date"){
        rs=validateDate(theForm.elements(field[i].fieldName),field[i].format,field[i].errorInfo);
      }
      else if(validatorType=="DateGroup"){
        rs=validateDateGroup(theForm.elements(field[i].year),theForm.elements(field[i].month),theForm.elements(field[i].day),field[i].errorInfo);
      }
      else if(validatorType=="Checkbox"){
        rs=validateCheckbox(theForm.elements(field[i].fieldName),field[i].errorInfo);
      }
      else if(validatorType=="Radio"){
        rs=validateRadio(theForm.elements(field[i].fieldName),field[i].errorInfo);
      }
      else if(validatorType=="Select"){
        rs=validateSelect(theForm.elements(field[i].fieldName),field[i].errorInfo);
      }
      else if(validatorType=="Email"){
        rs=validateEmail(theForm.elements(field[i].fieldName),field[i].errorInfo);
      }
      else{
        alert("????????????????, fieldName: "+field[i].name);
        return false;
      }
      if(rs==false){
        return false;
      }
    }
    else{//????????
      if(empty==false){
        var v = field[i].validator; // ??????validator????
        if(!v) continue;            // ????????????????,????????????
        var reg=new RegExp(v);
        if(reg.test(field[i].value)==false){
          alert(field[i].errorInfo);
          field[i].focus();
          return false;
        }
      }
    }
  }
  for(i=0;i<disableList.length;i++){
    disableList[i].disabled=true;
  }
  return true;
}

⌨️ 快捷键说明

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