Custom Validatorコントロール検証dropdownListとCookeの検証コード

1573 ワード

 <script type="text/javascript">//  DropDownList
    function checkDdlArea(obj,args){
        var ddlArea=document.getElementById("ddlArea");
        if(ddlArea.selectedIndex==0){
            args.IsValid=false;
            return;
        }
           args.IsValid=true;
    }
    
    function checkDdlComplaintType(obj,args){//  DropDownList
    var ddlComplaintType=document.getElementById("ddlComplaintType");
        if(ddlComplaintType.selectedIndex==0){
            args.IsValid=false;
            return;
        }
        args.IsValid=true;
    }
    
    function CheckCookie(obj,args){//  cookie     ,             
      var validateValue="";
      var search="CheckCode=";
      if(document.cookie.length>0){
                var offset=document.cookie.indexOf(search);
                if(offset!=-1){
                    offset+=search.length;
                   
                }
                var end=document.cookie.indexOf(";",search);
                if(end==-1){
                    end=document.cookie.length;
                }
                validateValue=document.cookie.substring(offset,end);
      }
      //    toUpperCase();
      if(args.Value.toLowerCase()!=validateValue.toLowerCase()){
            args.IsValid=false;
      }
    }
    </script>