  /*
  * not null the elements of the form except those marked false 
  * of not-null property.
  */
  function checkForm(theForm){
    /* put all the elements of the form into array.*/
    var elArr = theForm.elements;
    var validator;
    var valert;
    var valArray;
    var valertArray;
    var notNull;
    var elValue;
    var focusNum = 10000;
    var alertContent = null;
    var alertStatus = true;
    var notSelected;
    var notChecked;
    var zenCheck;
    var mostLength;

    /* delete exist alerts. */
    //deleteAlert();

    /*circulate the form elements for checks.*/
    for(var i = 0; i < elArr.length; i++){

      if(checkNode(elArr[i])){
        /*get corresponding property*/
        notNull       = elArr[i].getAttribute("notNull");
        validator     = elArr[i].getAttribute("validator");
        valert        = elArr[i].getAttribute("valert");
        elValue       = elArr[i].value;
        zenCheck      = elArr[i].getAttribute("zenCheck");
        notSelected   = elArr[i].getAttribute("notSelected");
        notChecked    = elArr[i].getAttribute("notChecked");
        mostLength    = elArr[i].getAttribute("mostLength");
        initLength    = elArr[i].getAttribute("initLength");
        /*
          if has this property,check the value,
          if the value is true,can null,
          else alert corresponding value.
        */
        if(notNull){
          if(notNull != "false"){
            alertContent = notNull ? notNull : "this value must not be null";
            if(isNull(elValue)){
              alert(alertContent);
              focusNum = focusNum < i ? focusNum : i;
              if(focusNum != 10000){
                elArr[focusNum].focus();
              }
              return false;
            }
          }
        }

        if(zenCheck){
          if(zenCheck != "false"){
          alertContent = zenCheck ? zenCheck : "this value must  be zenkaku";
            if(!isZen(elValue)){
              alert(alertContent);
              focusNum = focusNum < i ? focusNum : i;
              if(focusNum != 10000){
                elArr[focusNum].focus();
              }
              flg = 1;
              return false;
            }
          }
        }

        if(mostLength){
          if(mostLength != "false"){
            valArray = mostLength.split(";");
            m_mostLength = valArray[0];
            alertContent = valArray[1];
            if(!isMostLengh(elValue,m_mostLength)){
                alert(alertContent);
                focusNum = focusNum < i ? focusNum : i;
                if(focusNum != 10000){
                elArr[focusNum].focus();
                }
               return false;
            }
          }
        }
		if(initLength){
          if(initLength != "false"){
            valArray = initLength.split(";");
            m_initLength = valArray[0];
            alertContent = valArray[1];
            if(!isInitLengh(elValue,m_initLength)){
                alert(alertContent);
                focusNum = focusNum < i ? focusNum : i;
                if(focusNum != 10000){
                elArr[focusNum].focus();
                }
               return false;
            }
          }
        }

        if(notSelected){
          alertContent = notSelected ? notSelected : "this value must not be null";
          //elValue = elArr[i].selectedIndex;
          elValue = elArr[i].value;
          if(!isSelected(elValue)){
            alert(alertContent);
            focusNum = focusNum < i ? focusNum : i;
            if(focusNum != 10000){
             
            }
            return false;
          }
        }

        if(notChecked){
          if(notChecked != "false"){
            alertContent = notChecked ? notChecked : "this value must not be null";
            if(!isChecked(i,elArr)){
              focusNum = focusNum < i ? focusNum : i;
              if(focusNum != 10000){
                elArr[focusNum].focus();
              }
              return false;
            }
          }
        }

        if(validator){
          if(validator != ""){
            valArray = validator.split(";");
            valertArray = valert.split(";");
            for(var j = 0; j < valArray.length; j++){
              pattern = PatternsDict[valArray[j]];
              if(pattern == null || pattern ==""){
                continue;
              }
              if(!pattern.exec(elValue)){

                alert(valertArray[j]);

                focusNum = focusNum < i ? focusNum : i;

                if(focusNum != 10000){
                  elArr[focusNum].focus();
                }
                return false;
              }
            }
          }
        }

      }
    }
    return true;
  }

  /*
  *check node type and node name.
  *if node name is input or textarea ,return true.
  */
  function checkNode(node){
    if(node.nodeName=="INPUT" || node.nodeName=="input"){
      if(node.type=="text" || node.type=="password" || node.type=="file" || node.type=="checkbox" || node.type=="radio"){
        return true;
      }
    }
    if(node.nodeName=="TEXTAREA" || node.nodeName=="textarea"){
      return true;
    }
    if(node.nodeName=="SELECT" || node.nodeName=="select"){
      return true;
    }

    return false;
  }

  function isButton(node){
    if(node.nodeName=="INPUT" || node.nodeName=="input"){
      if(node.type=="button" || node.type=="submit"){
        return true;
      }
    }
    return false;
  }

  /*
  * not null the elements of the form except those marked false 
  * of not-null property.
  */
  function disableButtons(theForm){
    /* put all the elements of the form into array.*/
    var elArr = theForm.elements;
    var perPro;
    var elValue;

    /*circulate the form elements for checks.*/
    for(var i = 0; i < elArr.length; i++){
      if(isButton(elArr[i])){
        /*get corresponding property*/
        perPro = elArr[i].noDisable;
        /*if not this property,just jump to next circulation*/
        if(perPro){
          if(perPro == "true"){
            continue;
          }
        }
        else{
          /*set this button disabled for prevent iteration submit.*/
          elArr[i].disabled = true;
        }
      }
    }
  }

  /*
  * check this value is null or not.
  */
  function isNull(str){
    var trimStr = trim(str);
    if(trimStr == null || trimStr == ""){
      return true;
    }
    return false;
  }
 function isSelected(str){
    var trimStr = trim(str);
    if(trimStr == "0"){
      return false;
    }
    return true;
  }
  function isChecked(num,elArr){
    for(var i=0; i<elArr.length; i++){
      if(elArr[i].id == elArr[num].id){
        if(elArr[i].checked) {
          return true;
        }
       }
     }
   return false;
  }

  function isMostLengh(str,mostLength){
    if(str == null || str == ""){
      return true;
    }
    if(str.length > mostLength){
      return false;
    }
    return true;
  }
 function isInitLengh(str,initLength){
    if(str == null || str == ""){
      return true;
    }
    if(str.length != initLength){
      return false;
    }
    return true;
  }

  function isZen(str){
      if(str == null || str == ""){
          return true;
      }
   for(i = 0; i < str.length; i++){
          if(escape(str.charAt(i)).length < 4){
              return false;
          }
      }
  return true;

  }