1.datebox:
1.1datebox 控件打开页面就验证:
1 $('#endDate').datebox({
2 required:true,
3 validateOnCreate:false
4 });
1.2datebox显示英文:
解决办法:引入easyui-lang-zh_CN.js(easyUI 下载的包里面有)
1.3datebox显示日期格式修改:
1 $.fn.datebox.defaults.formatter = function(date){ 2 var y = date.getFullYear(); 3 var m = date.getMonth()+1; 4 var d = date.getDate(); 5 return m+'/'+d+'/'+y; 6 }
1.4easyui-datebox禁止手动输入
1 $('#endDate').datebox({ 2 required:true, 3 prompt:"结束日期", 4 editable:false, 5 validType:'minDay["#stateDate"]', 6 validateOnCreate:false 7 });
1.5easyui-combobox动态更改 required参数
View Code
说明:当id为cc的combox 发生改变是,ID为dd的combox 禁用且非必须;
注意:
function iCheckChange(aChecked){
$('#dd').combobox(aChecked?'enable':'disable');
$('#dd').combobox('options').required = aChecked;
$('#dd').combobox('textbox').validatebox('options').required = aChecked;
$('#dd').combobox('validate');
};
$('#dd').combobox(aChecked?'enable':'disable'); 添加的时候,dd在form表单中,在取表单值的时候 不会取到dd;
即:
1 <script> 2 $(function(){ 3 4 $("#cc").combobox({ 5 onChange:function(newValue,oldValue){ 6 debugger 7 var params = $('#searchForm').serializeArray(); 8 console.log(JSON.stringify(params)); 9 iCheckChange(false); 10 $('#dd').combobox('setValue', 'CT'); 11 var params1 = $('#searchForm').serializeArray(); 12 console.log(JSON.stringify(params1)); 13 } 14 }) 15 }) 16 17 function iCheckChange(aChecked){ 18 $('#dd').combobox(aChecked?'enable':'disable'); 19 $('#dd').combobox('options').required = aChecked; 20 $('#dd').combobox('textbox').validatebox('options').required = aChecked; 21 $('#dd').combobox('validate'); 22 }; 23 24 </script>
控制台答应出来的结果:
[{"name":"state","value":"AK"},{"name":"state","value":""}]
[{"name":"state","value":"AK"}]