Hi Jörn,

Element IDs are unique to a page, whereas names are not. By this very
fact, it is problematic applying validation rules to a specific
element if that element's name exists multiple times (as will often be
the case, especially with checkboxes, radio buttons and mutliple-
selects).

The problem I have encountered doesn't refer to multiple forms on a
page, but rather multiple iterations of the form across pages, i.e.
when a user submits the form. The validation rules and messages are
the same for each form so the form's input IDs should be used as the
reference.

E.g. This is valid for two distinct pages with identical forms
Form1 has input IDs field1, field2, field3
Form2 has input IDs field1, field2, field3

Where field1, field..n IDs could be referenced by your validation
script and re-used for each form.

However, since my form has dynamic names, I would need to create
multiple iterations of the validation script, since after the first
iteration of the form, the names of the form fields are changed (with
a numeric increment).

There are two solutions to this problem, both of which are far from
ideal:

1. Dynamically create the JavaScript used to validate a page using a
server-side script
2. As you suggest, hack your plugin to use element IDs rather than
names.

I've decided the latter is out of the question since it is your plugin
and as soon as an upgrade is available, I will not be able to use it.
The former will have to be used for the time-being.

I would kindly suggest that you consider implementing IDs as
references in your plugin. This could be an attribute a developer has
to implement in their script, the default being name, the ideal
scenario being ID.

Since IDs by their nature are unique this will allow users of your
plugin to clearly identify which element the rule is acting upon.

Many thanks,
Simon.


On Jun 25, 11:24 am, "Jörn Zaefferer" <[EMAIL PROTECTED]>
wrote:
> Repeating the same IDs across forms won't work, IDs have to be unique.
> That is why the plugin relies on names, as those have to be unique
> (from the plugin point of view) only within their form.
>
> You can try to hack the plugin, replacing all element.name snippets
> with element.id, but I won't support that.
>
> Jörn
>
> On Wed, Jun 25, 2008 at 12:10 PM, Simon Whatley <[EMAIL PROTECTED]> wrote:
>
> > Hi Joern,
>
> > I have come across an interesting problem regarding your jQuery
> > Validation script that I am sure you already have a solution to, but I
> > can't find it!
>
> > I need the validation rules to look at the form input IDs rather than
> > the form input names. I have a form that iterates 10 times (when you
> > click next), so the the names of the inputs increment by 1 each time,
> > whilst the IDs stay the same. (This is not my doing, so I have to live
> > with the naming convention!)
>
> > For example:
>
> > Form1 has input names field1_1, field2_1, field3_1 and input ids
> > field1, field2, field3
> > Form2 has input names field1_2, field2_2, field3_2 and input ids
> > field1, field2, field3
>
> > I originally thought your jQuery Validation script looked at the IDs
> > on the page, so the same validation rules would apply for field1
> > whether on form1 or form2. However this is not the case.
>
> > How do I change your script to look at the ID?
>
> > Many thanks in advance for your help.
>
> > Simon

Reply via email to