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

But it seems that it will only output single message.

On Mon, Apr 14, 2008 at 1:07 AM, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:

>
> Jacky See schrieb:
>
> > I have put up a page to test.
> > http://www.seezone.net/dev/dateValiation.html
> >
> > I need to use different method for different group of dates.
> > In that case, a global dateRange method seems not possible?
> >
> >
> Thats a different issue. A better dateRange implementation could reuse the
> information provided via the groups-option, or use the DOM structure to find
> the associated element.
>
> Jörn
>



-- 
Best Regards,
Jacky
網絡暴民 http://jacky.seezone.net

Reply via email to