I see... the group's key is not related to the rules/method. So the group would force the underlying fields to only display one message?
This would be a problem because a field would also have its own message (like date format is incorrect). I tried my old demo, inputting all four fields with wrong date format and only two comes out. I think may be a more desirable way is to separate them... like... { rules: { //individual field date1: 'date requried', date2: 'date required', date3: 'date required', date4: 'date required' }, globalRules: { //I can't come up with appropriate name checkPlanDateRange: { group: 'date1 date2', rule: {dateRange:'plan'}, message: 'xxxxx' }, checkActualDateRange: { group: 'date3 date4', rule: {dateRange:'actual'}, message: 'yyyyy' } } } Just my two cents On Tue, Apr 15, 2008 at 4:20 AM, Jörn Zaefferer <[EMAIL PROTECTED]> wrote: > > Jacky schrieb: > > > I'm thinking if I can do this: > > > > rules:{ > > planFromDate: {dateRange:'plan'}, planToDate: {dateRange:'plan'} > > actualFromDate: {dateRange:'actual'}, actualToDate: > > {dateRange:'actual'} > > } > > groups: { > > dateRange: "planFromDate planToDate actualFromDate actualToDate" > > } > > > > $.validator.addMethod('dateRange',function(value,elem,param){ > > var f = $(elem).parents("form:eq(0)")[0]; > > from = f[param+'FromDate'].value; > > to = f[param+'ToDate'].value; > > if(!from || !to || > > /Invalid|NaN/.test(new Date(from)) || > > /Invalid|NaN/.test(new Date(to))) > > return true; > > return from && to && new Date(from) < new Date(to); > > },'wrong date range'); > > > Give this a try: > > rules:{ > planFromDate: {dateRange:'plan'}, planToDate: {dateRange:'plan'} > actualFromDate: {dateRange:'actual'}, actualToDate: {dateRange:'actual'} > } > groups: { > plan: "planFromDate planToDate", > actual: "actualFromDate actualToDate" > } > > $.validator.addMethod('dateRange',function(value,elem,param){ > var f = elem.form; > var from = f[param+'FromDate'].value; > var to = f[param+'ToDate'].value; > > if(!from || !to || > /Invalid|NaN/.test(new Date(from)) || /Invalid|NaN/.test(new > Date(to))) > return true; > return from && to && new Date(from) < new Date(to); > },'wrong date range'); > > Jörn > -- Best Regards, Jacky 網絡暴民 http://jacky.seezone.net