layui ri laydate的常规使用,并且日期最大不能超过当前日期

laydate的常规使用,分为两种方式实现日期组件

一、在 layui 模块中使用 下载layui   地址 :https://www.layui.com/  引入资源路径 js 和 css


通过下面这样加载

<input  id="birthDate" name="birthDate" class="form-control" >
<script>
    layui.use('laydate', function(){
        var laydate = layui.laydate;
 
        //执行一个laydate实例
        laydate.render({
            elem: '#birthDate', //指定元素
            max: getNowFormatDate()
        });
    });
 
    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var seperator2 = ":";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate
            + " " + date.getHours() + seperator2 + date.getMinutes()
            + seperator2 + date.getSeconds();
        return currentdate;
    }
</script>
原文地址:https://www.cnblogs.com/mica/p/11739153.html