function compareError(sender, args) {
          
                var dateStart = $("#<%=txtStartTime.ClientID %>").val().replace(/\-/g, "\/");
                var dateEnd = $("#<%=txtEndTime.ClientID %>").val().replace(/\-/g, "\/");
                if (dateStart.length > 0 && dateEnd.length > 0) {
                    if (dateStart > dateEnd) {
                        args.IsValid = false;
                    }
                    else {
                        args.IsValid = true;
                    }
                }
                else {
                    args.IsValid = true;
                }   

      }          

 

  <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="compareError" ForeColor="red" ErrorMessage="截止日期大于起始日期!"></asp:CustomValidator>
             
posted on 2012-07-26 15:20  万德源  阅读(332)  评论(0编辑  收藏  举报