方式一:直接利用控件属性——

         <%--开始日期不能晚于结束日期;最大间距1年--%>
            &nbsp;&nbsp;创建时间:<input />

方式二:自定义函数——

  &nbsp;&nbsp;创建时间:<input />

 

/*CCM:控制时间控件间隔一年*/
function limitMonthDate(e, idname) {
    var DateString;
    if (e == 2) {
        var beginDate = $dp.$(idname).value;
        var time = new Date();
        var m = time.getMonth() + 1;
        var t = time.getFullYear() + "-" + m + "-" + time.getDate();
        if (beginDate != "" && beginDate != null) {
            var limitDate = new Date(beginDate);
            var years = limitDate.getFullYear() + 1;
            var months = limitDate.getMonth() + 1;
            var days = limitDate.getDate();
            DateString = years + '-' + months + '-' + days;
            return (Date.parse(t) < Date.parse(DateString)) ? t : DateString;
        } else {
            return t;
        }
    }
    if (e == 1) {
        var endDate = $dp.$(idname).value;
        if (endDate != "" && endDate != null) {
            var limitDate = new Date(endDate);
            var years = limitDate.getFullYear() - 1;
            var months = limitDate.getMonth() + 1;
            var days = limitDate.getDate();
            DateString = years + '-' + months + '-' + days;
            return DateString;
        }
    }
}

相关文章:

  • 2022-02-18
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案