欧美激情网,国产欧美亚洲高清,欧美屁股xxxxx,欧美群妇大交群,欧美人与物ⅴideos另类,区二区三区在线 | 欧洲

知識學堂
  • ·聯系電話:+86.023-75585550
  • ·聯系傳真:+86.023-75585550
  • ·24小時手機:13896886023
  • ·QQ 咨 詢:361652718 513960520
當前位置 > 首頁 > 知識學堂 > 網站建設知識
一些Javascript驗證腳本
更新時間:2012-01-19 | 發(fā)布人:本站 | 點擊率:441
幾個有用的Javascript驗證腳本,以下是代碼片段。


function isNum(num,low,hi) {
  if(isNaN(num)||numhi)return false;
  return true;
}

function isValidIP(v) {
  nums=v.split(".");
  if(nums.length!=4)return false;
  for(j=0;j<4;j++){
    if(!isNum(nums[j],0,255))return false;
  }
  return true;
}

function checkIP(Object,Desc,MaybeEmpty)
{
  var strValue= Object.value;
  
  if(MaybeEmpty){
     if(strValue.length ==0){
        return true;
      }
  }
  
  if(isValidIP(strValue)==false)
  {
    alert(Desc + " Format Error!");
    Object.focus();
    return false;
  }
  return true;
}

function checkPort(Object,Desc,lowest,MaybeEmpty)
{

  var pattern=/^\d{4,5}$/;
  var strValue= Object.value;
  
  
  if(MaybeEmpty){
    if(strValue.length ==0){
        return true;
      }
  }
  
  if(strValue.match(pattern) == null)
  {
    alert(Desc + " Format Error!");
    Object.focus();
    return false;
  }
  
  if (strValue65535)
  {
      alert(Desc + " Format Error!");
      Object.focus();
      return false;
  }
  
  return true;
}


function checkFitLongStr(Object,Desc,MaybeEmpty)
{

  var pattern=/^\S{0,25}$/;
  var strValue= Object.value;
  
  if(MaybeEmpty){
     if(strValue.length ==0){
        return true;
      }
  }
  if(strValue.match(pattern) == null)
  {
    alert(Desc + " Format Error!");
    Object.focus();
    return false;
  }
  
  return true;
}

function checkFitLongNum(Object,Desc,MaybeEmpty)
{

  var pattern=/^\d{0,8}$/;
  var strValue= Object.value;
  
  if(MaybeEmpty){
     if(strValue.length ==0){
        return true;
      }
  }
  if(strValue.match(pattern) == null)
  {
    alert(Desc + " Format Error!");
    Object.focus();
    return false;
  }
  
  return true;
}

function checkGC(Object,Desc)
{
  var pattern = /^\-{0,1}\d{1,2}$/
  var strValue = Object.value;
  if (strValue.length ==0){
     return true;
  }
  
  if(strValue.match(pattern) == null)
  {
    alert(Desc + " Format Error!");
    Object.focus();
    return false;
  }
  
  if (strValue < -12 ||strValue > 18)
  {
    alert(Desc + " Format Error!");
    Object.focus();
    return false;
  }
  return true;
}