The plugin is architectured around unique names, so there is no
obvious way out. The plugin is already quite tolerant in respect to
dynamic forms, so this is a worthwhile topic. I'd be happy to
collaborate with you on this, where you do the research and we try to
find a solution based on that, together.

By research I'm referring to an extensive code review, looking for the
various places where element names are used, and how they could be
modified to remove the unique requirement (eg. indexing in the
internal data structures).

Jörn

On Tue, Jul 15, 2008 at 5:12 PM, ldodds <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I've built a dynamic form that I want to validate using the JQuery
> validate plugin. However I've hit a snag which I think is related to
> how I'm naming form elements. I wondered whether anyone else has had
> the same problem (or might have a solution!)
>
> The dynamic aspects of the form are implemented with a little
> microformat and a use of the JQuery clone() method. I have something
> like:
>
> <div class="repeated">
>  <input type="text" name="ex:email" value=""/>
> </div>
>
> My code picks up on "repeated" form sections and adds some controls to
> enable to the user to add/remove sections to the form. In this case,
> the ability to add multiple email addresses. That bit works fine.
>
> What I want to do is just add class="required email" to markup, and
> have each individual email address be validated.
>
> However at the moment the JQuery Validate plugin treats all of the
> inputs as the same, i.e. if I click to add a second email address
> field, with the first value being invalid and the second valid, then
> the plugin seems to only ever be validating the original value.
>
> I think this is because the plugin is using the field name attributes
> as a key?
>
> Yes, the obvious answer is to give all the controls unique names, but
> I'd like to avoid that if possible as the field names are used
> elsewhere and I'd rather avoid having to munge them to add/remove a
> unique suffix (e.g. ex:email-1).
>
> Any ideas?
>
> Cheers,
>
> L.
> --
> http://www.ldodds.com/blog
>

Reply via email to