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?

On 4月11日, 上午6時03分, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> Jacky See schrieb:> Hi,
>
> > Some question on the config of validation plugins.
> > Suppose there are #fromDate and #toDate fields (using ui.datepicker).
> > I have added these custom rules
> > [...]
>
> > It will output two messages of 'Please input correct date range'.
> > How can I make it only ouput single one?
>
> I've implemented a solution, please give the latest revision a 
> try:http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js
>
> You need to specify which elements to group using the new groups-option.
>
> A usage example (actually a test, will later add it to docs) is 
> here:http://dev.jquery.com/view/trunk/plugins/validate/test/messages.js
>
> The interesting parts:
>
> <form id="dateRangeForm">
>         <input id="fromDate" name="fromDate" class="requiredDateRange" />
>         <input id="toDate" name="toDate" class="requiredDateRange" />
>         <span class="errorContainer"></span>
> </form>
>
> $.validator.addClassRules({
>         requiredDateRange: {required:true, date:true, dateRange:true}});
>
> $.validator.addMethod("dateRange", function() {
>         return new Date($("#fromDate").val()) < new 
> Date($("#toDate").val());}, "Please specify a correct date range.");
>
> $("#dateRangeForm").validate({
>         groups: {
>                 dateRange: "fromDate toDate"
>         },
>         errorPlacement: function(error) {
>                 form.find(".errorContainer").append(error);
>         }
>
> });
>
> You'll most likely have to skip or modify the errorPlacement option, but
> the rest should work fine.
>
> Your feedback on it is very welcome.
>
> Jörn

Reply via email to