I'm trying to modify my custom method, as follows:

        $.validator.addMethod('expiryDate', function(element){
                var presentDate = new Date();
                var selectedDateHash = parseInt($('#select-cardpayment-
expirymonth').val(), 10) + parseInt(($('#select-cardpayment-
expiryyear').val() * 12), 10);
                var presentDateHash = (presentDate.getMonth()+1) +
(presentDate.getFullYear() * 12);
                return this.optional(element) || selectedDateHash >
presentDateHash;
        }, parseMessageText('errors.paymentForm.cardPayment.expiryDate'));

Unfortunately this doesn't work either; in fact, in Firefox the
validation silently fails to execute /at all/ once I call
this.optional(). I can't even reference it with the Firebug console
without it stopping JS execution. What gives? I wasn't even aware such
a method existed...?

On Jun 19, 4:22 pm, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> You need to make sure that your custom method checks for optional
> elements. Check those additional methods for 
> examples:http://dev.jquery.com/view/trunk/plugins/validate/additional-methods.js
>
> Jörn
>
> On Wed, Jun 18, 2008 at 2:20 PM, kapowaz <[EMAIL PROTECTED]> wrote:
>
> > Alright, I've found the bug with the above code (the callback function
> > itself doesn't return true or false; only the anonymous method inside
> > it does), and corrected it. However I've since stumbled upon another
> > problem; if any field uses a callback method to determine required
> > status, but *also* happens to use a custom validation method, it will
> > always be flagged as required.
>
> > I've augmented my demo 
> > athttp://www.kapowaz.net/files/conditional-validation.html
> > to demonstrate this problem in action. Might this be a bug within the
> > plugin itself, or am I doing something else wrong?

Reply via email to