js限制选择的日期格式不能大于当前日期

 时间:2026-04-23 15:04:48

1、<script>

$(document).ready(function(){

     $("#btnSave").click(function(){

         var feeConfirmDate = $("#feeConfirmDate").val();

        var d1 = new Date(feeConfirmDate);

         //时间格式验证:必须为非空的时间格式

        if(d1 == "Invalid Date"){ 

           alert("费用确认日期必填,同时不能大于现在时间");

        }else{

            //取当前年月日,舍去时分秒

             var d = new Date();

            d = new Date(d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate());

           d1 = new Date(d1.getFullYear() + "-" + (d1.getMonth() + 1) + "-" + d1.getDate());

          var n = d.getTime() - d1.getTime();

              if(n<0){

                  alert(n+"-----------费用确认日期必填,同时不能大于现在时间");

              }else {

                  alert(n+"----验证通过");

             }

      }

   });

});

</script>

2、<div class="col-xs-7">

<input type="text" class="form-control" id="feeConfirmDate" name="feeConfirmDate">

 <button type="button" id="btnSave">保存</button>

</div>

1、测试效果

js限制选择的日期格式不能大于当前日期

js限制选择的日期格式不能大于当前日期

js限制选择的日期格式不能大于当前日期

  • access显示未关连对象缘由
  • Access如何设置默认字体字号
  • ACCESS二级考试:删除字段的详细操作
  • Access怎么创建表
  • access怎么实现函数表达式查询内容
  • 热门搜索
    旅游seo 枣庄旅游景点大全 海南旅游业 福州 旅游 国外旅游网站 公司旅游通知 海涛旅游 徐州旅游攻略 9月份适合去哪里旅游 泰山旅游门票