layDate 日期与时间组件设置最小时间

官网链接:https://www.layui.com/laydate/

如何设置当前时间为最小时间


<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>使用 layDate 独立版</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="apple-mobile-web-app-status-bar-style" content="black"> 
  <meta name="apple-mobile-web-app-capable" content="yes">
  <meta name="format-detection" content="telephone=no">

  <style>
  body{padding: 20px;}
  .demo-input{padding-left: 10px; height: 38px; min-width: 262px; line-height: 38px; border: 1px solid #e6e6e6;  background-color: #fff;  border-radius: 2px;}
  .demo-footer{padding: 50px 0; color: #999; font-size: 14px;}
  .demo-footer a{padding: 0 5px; color: #01AAED;}
  </style>
</head>
<body>

<input type="text" class="demo-input" placeholder="请选择日期" id="test2">



<script src="laydate/laydate.js"></script> <!-- 改成你的路径 -->
<script>
lay('#version').html('-v'+ laydate.v);


//执行一个laydate实例
laydate.render({
    elem: '#test2', //指定元素,
    type: 'datetime',
    min: 'new Date()'

});


</script>


</body>
</html>

浏览器中预览,点击选择日期,可以看到只可以选择今天和之后的日期,不可以选择之前的
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/guo_qiangqiang/article/details/89018849
今日推荐