easyui datebox不能大于当前时间

easyui datebox日期控件不能大于当前时间
最近使用easyui中DataGrid数据表格, 其中应用了datebox日期控件
  • 1.添加datebox必填项属性: required:true
  • 2.datebox时间框禁用编辑: editable:false
  • 3.判断选择时间不能大于当前时间
DataGrid 添加必填项&禁用编辑
<table id="seventhDG" class="easyui-datagrid" style="width:98%;height:auto" data-options="
                        iconCls: 'icon-edit',
                        singleSelect: true,
                        toolbar: '#seventhRow',
                        onClickRow: onClickRow
                    ">
        <thead>
            <tr>
                <th data-options="field:'disease_name',width:350,align:'center',editor:'textbox'">输血原因</th>
                <th data-options="field:'disease_remark',width:250,align:'center',editor:'textbox'">备注</th>
                <th data-options="field:'diagnosis_date',width:142,align:'center',editor:{
                    type: 'datebox',
                    //必填项
                    options:{
                        required:true
                    }
                    //禁用编辑
                },editable:false">输血日期</th>
        </tr>
    </thead>
</table>
判断不能大于当前时间
// 判断用户选择日期 不能大于  当前日期
$.extend($.fn.datagrid.defaults.editors, {
    datebox: {
        init: function (container, options) {
            var input = $('<input type="text">').appendTo(container);
            input.datebox(options).datebox('calendar').calendar({
                // 验证选择时间 <= 当前时间
                validator: function (date) {
                    var now = new Date();
                    return date <= now;
                }
            });
            return input;
        },
        destroy: function (target) {
            $(target).datebox('destroy');
        },
        getValue: function (target) {
            return $(target).datebox('getValue'); //获得旧值  
        },
        setValue: function (target, value) {
            $(target).datebox('setValue', value); //设置新值的日期格式  
        },
        resize: function (target, width) {
            $(target).datebox('resize', width);
        }
    }
});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值