CustomValidator控件验证dropdownList和Cooike中的验证码

 <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>

 

你可能感兴趣的:(JavaScript)