Forum


05:14

18/06/2011

how to validate two fields in grid form ,eg.begin_date and end_date,begin_date must less than end_date?
colMode:
{ name: 'Begin_Date', label: 'Begin_Date', width: 80, formatter: 'date', formatoptions: { newformat: 'Y-m-d' }, align: "center", editable: true, editoptions: { size: 10, dataInit: function(el) { $(el).datepicker({ dateFormat: 'yy-mm-dd' }); },
defaultValue: GetCurrentDate(document.all._Today.value)
}, formoptions: { elmsuffix: '*' }, editrules: { required: true, custom: true, custom_func: function(value, colname) { ..... } }
},
{ name: 'End_Date', label: 'End_Date', width: 80, formatter: 'date', formatoptions: { newformat: 'Y-m-d' }, align: "center", editable: true, editoptions: { size: 10, dataInit: function(el) { $(el).datepicker({ dateFormat: 'yy-mm-dd' }); },
defaultValue: GetCurrentDate(document.all._Today.value)
}, formoptions: { elmsuffix: '*' },editrules: { required: true, custom: true, custom_func: function(value, colname) { ..... }
}
function(value, colname) { ..... }??
thanks!
10:42

18/06/2011

i found a way to solve this problem:
editrules: { required: true, custom: true, custom_func: function(value, colname) { return CheckDate($("#Begin_Date").val(), $("#End_Date").val()); } }
function CheckDate(b_date, e_date) {
var d1 = toDate(b_date,"yyyy-MM-dd");
var d2 = toDate(e_date, "yyyy-MM-dd");
if ((!checkDateFormate(b_date)) || (d1 == null)) {
return [false, "开始日期 æ ¼å¼é”™è¯¯"];
}
if ((!checkDateFormate(e_date)) || (d2 == null)) {
return [false, "ç»“æŸæ—¥æœŸ æ ¼å¼é”™è¯¯"];
}
if (d2 < d1) {
return [false, "ç»“æŸæ—¥æœŸ 必须大于 开始日期"];
}
return [true, ""];
}
Most Users Ever Online: 715
Currently Online:
34 Guest(s)
Currently Browsing this Page:
1 Guest(s)
Top Posters:
OlegK: 1255
markw65: 179
kobruleht: 144
phicarre: 132
YamilBracho: 124
Renso: 118
Member Stats:
Guest Posters: 447
Members: 11373
Moderators: 2
Admins: 1
Forum Stats:
Groups: 1
Forums: 8
Topics: 10592
Posts: 31289
Newest Members:
, razia, Prankie, psky, praveen neelam, greg.valainis@pa-tech.comModerators: tony: 7721, Rumen[Trirand]: 81
Administrators: admin: 66