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);
}
}
});