Let just get this straight, I consider this invalid and useless html:

<form>
<input id="e1" name="e1_1" />
<input id="e2" name="e1_2" />
</form>
<form>
<input id="e1" name="e2_1" />
<input id="e2" name="e2_2" />
</form>

While this is valid and useful, and works fine with the validation plugin:

<form>
<input id="e1_1" name="e1" />
<input id="e1_2" name="e2" />
</form>
<form>
<input id="e2_1" name="e1" />
<input id="e2_2" name="e2" />
</form>

So either of us is missing something, which we need to clear up at first.

Let me know what you think, I sure hope to find a solution to this
that works for both of us.

Jörn

On Wed, Jun 25, 2008 at 12:58 PM, Simon Whatley <[EMAIL PROTECTED]> wrote:
>
> Hi Jörn,
>
> IDs are unique to the page rather than across forms, names do not have
> to be. The forms I refer to are not on the same page, but on a new
> instance of the page when a user clicks the submit button. The rule
> should/could therefore apply to the ID and not the name, since the
> name can be dynamic.
>
> There are two ways I can get around this. Use a server-side scripting
> language to dynamically output the correct JavaScript and therefore
> rules and messages or hack the validation plugin. It's not great doing
> either.
>
> I will try looking at the plugin option since it is a more sensible
> approach. I would suggest that the plugin support element IDs as this
> is the only way you can guarantee a rule be applied to a specific
> element (assuming people adhere to the uniqueness of an ID). If you
> can somehow allow the plugin to be based on either name or ID, to be
> specified by the developer and defaulting to name, it will allow for
> backwards compatibility.
>
> If I get something working with element.id, I'll send the code over to
> you.
>
> 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