zoukankan      html  css  js  c++  java
  • 比较经典的日期判断

                    <asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="ClientValidate"
                            Display="Dynamic" ErrorMessage="起始日期不能大于结束日期" ForeColor="Red"></asp:CustomValidator>
    <script type="text/javascript" language="javascript">
        function  ClientValidate(sender, args)
        {
          var flag = false;
          var controlid = sender.id.substr(0,sender.id.length-("CustomValidator1").length);
          var startDate =  document.getElementById(controlid+"startDate").value;
          var endDate =  document.getElementById(controlid+"endDate").value;

         if(GetDate(startDate) <= GetDate(endDate) )
            return true;
          if (flag)
            args.IsValid = true;
          else
            args.IsValid = false;
        }
        function GetDate(inputdate)
        {
            var posyear = inputdate.indexOf('年');
            var posmonth = inputdate.indexOf('月');
            var posday = inputdate.indexOf('日');
           var year = inputdate.substr(0,4);
         var month = inputdate.substr(posyear+1,2);
         var day = inputdate.substr(posmonth+1,2);
            var date = new Date(year, month, day);
            return date;
        }
        </script>

  • 相关阅读:
    Neo4j-3.0.3 (Debian 8)
    python学习之argparse模块
    变异系数
    孪生素数
    统计学中的自由度
    兰伯特余弦定理(Lambert)
    椒盐噪声
    沥青路面磨损后泛白的原因
    朗伯体
    绕坐标轴旋转的矩阵
  • 原文地址:https://www.cnblogs.com/glume/p/1075020.html
Copyright © 2011-2022 走看看