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

📄 pub.js

📁 shopping home JSP system
💻 JS
📖 第 1 页 / 共 2 页
字号:
  }
}

return MSG_CHECK_SUCCESS;
}
    function check(sItemName, sCheck, nMinLen, nMaxLen, chkFlg) {
    sRet = checkItem(sCheck, nMinLen, nMaxLen, chkFlg);
    if (sRet != MSG_CHECK_SUCCESS) {
  sErr += sItemName + sRet + "\n";
  return false;
}
return true;
}
//3.检查电子邮件表单的格式是否正确
    function checkEmail(str) {
    var i;
    var len = str.length;
    var aPos = str.indexOf("@");
    var dPos = str.indexOf(".");
    var aaPos = str.indexOf("@@");
    var adPos = str.indexOf("@.");
    var ddPos = str.indexOf("..");
    var daPos = str.indexOf(".@");
    var chkStr =
    "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-_@.";

    if ( (aPos <= 0) || (aPos == len - 1) || (dPos == len - 1) || (adPos > 0) ||
        (daPos > 0) ||
        (str.charAt(len - 1) == "@") || (str.charAt(len - 1) == ".") ||
        (aaPos > 0) || (ddPos > 0)) {
  return false;
}
if (str.indexOf("@", aPos + 1) > 0) {
  return false;
}

for (i = 0; i < len; i++) {
  if (chkStr.indexOf(str.charAt(i)) < 0) {
    return false;
  }
}
return true;
}
//4.检查电话号码表单的格式是否正确
    function checkPhone(str) {
    var i = str.indexOf("--");
    var len = str.length;
    if (i >= 0) {
  return false;
}
i = str.indexOf("-");
    if ( (i == 0) || (i == len - 1)) {
  return false;
}
else if (i > 0) {
  i = str.lastIndexOf("-");
  if (i == len - 1) {
    return false;
  }
  str = removeChar(str, "-");
}
if (!checkNumber(str)) {
  return false;
}
else {
  return true;
}
}
//5.检查是否为英文字母
    function checkEngNum(str) {
    if (str == null || str == "") {
  return true;
}

var c = new RegExp();
    c = / ^ [\d | a - zA - Z] + $ / ;
    if (c.test(str)) {
  return true;
}
else {
  return false;
}
}
//6.检查是否为数字型元素
    function checkNumber(str) {
    var i;
    var len = str.length;
    var chkStr = "1234567890";
    if (len == 1) {
  if (chkStr.indexOf(str.charAt(i)) < 0) {
    return false;
  }
}
else {

  if ( (chkStr.indexOf(str.charAt(0)) < 0)) {
    return false;
  }
  for (i = 1; i < len; i++) {
    if (chkStr.indexOf(str.charAt(i)) < 0) {
      return false;
    }
  }
}
return true;
}
//7.检查是否为浮点型元素
    function checkFloat(str) {
    var i;
    var len = str.length;
    var chkStr = "1234567890.";
    if (len == 1) {
  if (chkStr.indexOf(str.charAt(i)) < 0) {
    return false;
  }
}
else {
  //if ((chkStr.indexOf(str.charAt(0)) < 0) || (str.charAt(0) == "0")) {
  if ( (chkStr.indexOf(str.charAt(0)) < 0)) {
    return false;
  }
  for (i = 1; i < len; i++) {
    if (chkStr.indexOf(str.charAt(i)) < 0) {
      return false;
    }
  }
}
return true;
}
//8.检查是否为日期
    function checkDate(str) {
    str = convDate(str, "/");
    if ( (str.length != 8) || !checkNumber(str)) {
  return false;
}
var year = str.substring(0, 4);
    var month = str.substring(4, 6);
    var day = str.substring(6, 8);
    dayOfMonth = new Array(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
    if ( (month < 1) || (month > 12)) {
  return false;
}
if ( (day < 1) || (day > dayOfMonth[month - 1])) {
  return false;
}
if (!checkLeapYear(year) && (month == 2) && (day == 29)) {
  return false;
}
return true;
}

 /****************************************七、子窗口的弹出与关闭*************************************************/
var childWindow = null;
var fatherWindow = null;
var form = null;

// 打开子窗口,在打开之前定义父窗口的名字
function openNew(URL, Width, Height) {

 //   window.name = "fatherWindow";
    closeChildNew();
   showx = event.screenX - event.offsetX - Width; // + deltaX;
    showy = event.screenY - event.offsetY - Height - 30; // + deltaY;
  var features =
    'width = ' +Width +
    ',height = ' +Height +
    ',left = ' +showx +
    ',top = ' +showy +
    ',directories = no, localtion = no, menubar = no, status = yes, toolbar = no,scrollbars = yes, resizeable = no';
    childWindow = window.open(URL, "", features);
}
// 如果已经有子窗口打开,则关闭之
    function closeChildNew() {
    if (childWindow && childWindow.open && !childWindow.closed) {
  childWindow.close();
}
}

// 关闭子窗口的同时,进行提交,并将提交之后的得页面转到父窗口,关闭子窗口
// 这里本应该是使用同一个函数,但是时间有点急,就
    function closeChildWindow(fatherForm, childForm, actionType) {
    childForm.actionType.value = actionType;
    childForm.target = "mainFrame";
    childForm.submit();
    window.close();
    return true;
}

    function closeChildWindowNew(childForm, actionType) {
    childForm.actionType.value = actionType;
    childForm.target = "fatherWindow";
    childForm.submit();
    window.close();
    return true;
}
    /* SelectAllOptions ***********************************************************/
// set all options to selected
    /******************************************************************************/
    function SelectAllOptions(theSelect) {

    for (var i = 0; i < theSelect.options.length; i++) {

  theSelect.options[i].selected = true;

}

}
//改变选中行的css;author:lithlin   for rdms only!
    function changeCss(CB, className) {
    if (CB.checked) {
  while (CB.tagName != "TR") {
    CB = CB.parentElement;
  }
  CB.className = "ListTrLight";
}
else {
  while (CB.tagName != "TR") {
    CB = CB.parentElement;
  }
  CB.className = className;
}
}
//在两个选择框中移动数据
    function MoveOptionsTo(fromSelect, toSelect) {
    var myform = document.expertslistform;
    for (i = 0; i < fromSelect.options.length; i++) {
  // alert(fromSelect.options.length);
  if (fromSelect.options(i).selected == true) {
    j = toSelect.options.length - 1;
    //  alert(toSelect.options.length);
    for (; j >= 0; j--) {
      if (fromSelect.item(i).value == toSelect.item(j).value) {
        break;
      }
    }
    if (j < 0) {
      var name = fromSelect.item(i).text;
      var newOpt = new Option(name, fromSelect.item(i).value);
      toSelect.add(newOpt);

    }
  }
}
}
//移走某个多选框中的数据
    function removeItem(from) {
    for (i = from.options.length - 1; i >= 0; i--) {
  if (from.options(i).selected == true) {
    from.remove(i);
  }
}
}
//===============全选按钮操纵所有多选框==========================================
  function checkAll() {

    var state = document.forms[0].selectstate.value;
    var j = 0;
    for (var i = 0; i < document.forms[0].elements.length; i++) {
  var e = document.forms[0].elements[i];
  if (e.name == 'selected'){
     
      e.checked = state;
      if(j%2==0){
     changeCss(e,'9t_center');
	}else{
	changeCss(e,'9t_center_bg');
}
    j++	
 }
}
if (state == "on") {
  document.forms[0].selectstate.value = "";
}
else {
  document.forms[0].selectstate.value = "on";
}
}

function checkAllByName(selectedName, stateCtrl) {
  var state = stateCtrl.value;
  var j = 0;
  for (var i = 0; i < document.forms[0].elements.length; i++) {
  	var e = document.forms[0].elements[i];
	  if (e.name == selectedName){
	      e.checked = state;
		}
		j++	
 	}
	
	if (state == "on") {
	  stateCtrl.value = "";
	}
	else {
	  stateCtrl.value = "on";
	}
}

//控制键盘输入时只能输入数字和小数点
function floatOnly()
{
  if ( !(((window.event.keyCode >= 48) && (window.event.keyCode <= 57))|| (window.event.keyCode == 13)|| (window.event.keyCode == 46)))
  {
     window.event.keyCode = 0 ;
  }
} 


//将值转化成Float型
function turnToFloat(name){     
   trimValue(name);
   var value=document.all[name].value; 
   value = getFloat(value,2);
   document.all[name].value=value;
} 

//对数字型数据值进行整理
function trimValue(name){
   var value = document.all[name].value;
   if(value==""||parseFloat(value)==0){
      document.all[name].value=0;
      return;
   }
   //去掉开头的0
   for(var i=0;i<value.length;i++){   
     if(value.charAt(i)==0)
       continue;
     else{
       value = value.substring(i);
       break;
     }  
   }
   document.all[name].value =value;
}

//百分比计算,结果保留小数点两位
function getRatio(num1,num2){
    if(num2==0)
      return 0;
    var result=num1/num2*100;
    return getFloat(result+"",2);
}


function selectLeftMenu(selfIndex, indexNum) {
	if(eval("document.all.child" + selfIndex + ".style").display =='none') {
		eval("document.all.child" + selfIndex + ".style").display = "";

		for(i=0; i< parseInt(indexNum); i++) {
			if(i == parseInt(selfIndex)) continue;						
			if(eval("document.all.child" + i))				
				eval("document.all.child" + i + ".style").display = 'none';
		}
	} else {
		eval("document.all.child" + selfIndex + ".style").display = "none";
	}
	
}

function disableRightClick(e)
{
  var message = "Right click disabled";
  
  if(!document.rightClickDisabled) // initialize
  {
    if(document.layers) 
    {
      document.captureEvents(Event.MOUSEDOWN);
      document.onmousedown = disableRightClick;
    }
    else document.oncontextmenu = disableRightClick;
    return document.rightClickDisabled = true;
  }
  if(document.layers || (document.getElementById && !document.all))
  {
    if (e.which==2||e.which==3)
    {
      return false;
    }
  }
  else
  {
 
    return false;
  }
}


function getFloatCtrlValue(ctrlNameHead, index) {
	if(index != -1 )
		ctrlName = ctrlNameHead + index;
	else 
		ctrlName = ctrlNameHead;
		
	ctrl = document.all[ctrlName]
	if(ctrl == null || trim(ctrl.value) == "") return 0;
	
	return parseFloat(ctrl.value);
	
}

function setFloatCtrlValue(ctrlNameHead, index, floatValue) {
	if(index != -1)
		ctrlName = ctrlNameHead + index;
	else 
		ctrlName = ctrlNameHead;
	ctrl = document.all[ctrlName];
	
	if(ctrl == null) return;
	
	return ctrl.value = floatValue;
	
}

⌨️ 快捷键说明

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