For rules("add") to work, the element's form has to be validated, that
is, call $("form").validate() first. I've updated the documentation
accordingly.

Not sure why the attr-approach failed, I'll take a look at that.

Jörn

On Thu, Oct 9, 2008 at 2:37 AM, BobS <[EMAIL PROTECTED]> wrote:
>
> I'm working on a server-side component that will generate all of my
> jQuery validation rules from xml metadata, so I'm trying to
> dynamically add rules one at a time.
>
> My first attempt was to use the rules( "add", rules ) syntax, but I'm
> getting an error on page load:
>
> jQuery.data(element.form, "validator") is undefined
>
> Here's the syntax I'm using:
>
> $("#VerifyPassword").rules('add',{equalTo: '#UserPass'});  which seems
> to be correct according to the docs.
>
> So, I decided to try setting attributes instead, which works fine for
> the equalTo. For example, this works:
>
> $("#VerifyPassword").attr('equalTo','#UserPass');
>
> But when trying to use attr to set a range I cannot figure out what to
> pass in for the range.
>
> I've tried:
> $("#UserPass").attr('rangelength','[5,10]'); -> yeilds the message
> "Please enter a value between NaN and 5 characters long."
> $("#UserPass").attr('rangelength',[5,10]);  -->  yields the message
> "Please enter a value between 5 and NaN characters long."
> var theRange = [5,10]; $("#UserPass").attr('rangelength',theRange);  --
>>  yields the message "Please enter a value between 5 and NaN
> characters long."
>
> So, I really have 2 questions:
>
> 1. How can I a rule using the rules( "add", rules ) syntax, which
> would be my preferred approach?
> 2. If I need to add a validation using attr, what format do I use to
> pass in the value of the rangelength attribute?
>
> Thanks in advance for any help anyone can provide,
> Bob
>

Reply via email to