FYI, i added the following two lines to my custom function, and all
is well.
$.fn.validateForm = function() {
var elems = this[0].elements || this;
elems = $($.merge(elems, []));
elems.each(function() {
// do custom validation stuff with each element
}
}
(FYI, i need the ability to pass a set of elements to this function,
because sometimes i want to perform validation on every element (by
passing form.elements), and sometimes i want to pass a subset of
elements (to validate part of a form) for reasons that are esoteric
to the site i'm working on.)
thanks brandon and everyone,
-p
On Nov 6, 2006, at 11:57pm, Brandon Aaron wrote:
> This actually doesn't fix the issue and doesn't seem like it is
> fixable since IE makes no distinction between the form node and the
> form.elements collection. The workaround is to do it like this:
>
> $($.merge(form.elements, []));
>
> --
> Brandon Aaron
>
>
>
> On 11/6/06, Brandon Aaron <[EMAIL PROTECTED]> wrote:
>> Okay ... looking through all the properties of the form.elements
>> nodelist in IE reveals that it is exactly the form element as you
>> said. That also means it has a reference to the elements property. So
>> to fix this 'special case' I added this:
>>
>> this.get( a.constructor == Array || a.length != undefined && (
>> !a.nodeType || (jQuery.browser.msie && a.elements) ) && a[0] !=
>> undefined && a[0].nodeType ?
>>
>> This appears to work fine but I don't know if it will affect
>> anything else.
>> http://brandon.jquery.com/testing/node_lists/
>>
>> If it doesn't break anything else, then we should probably get this
>> and the fix for #164 in SVN and get another point release out the
>> door.
>>
>> --
>> Brandon Aaron
>>
>> On 11/6/06, Dave Methvin <[EMAIL PROTECTED]> wrote:
>>>> Do you know what the nodeType test is for on that line?
>>>
>>> That nodeType test is trying to tell the difference between a
>>> NodeList and a
>>> DOMElement. If it's a DOMElement it will have a non-zero nodeType.
>>>
>>>> What would break if we took it out?
>>>
>>> If you took it out, any DOMElement with a .length property would
>>> be treated
>>> like a list and not an element. For example, the form element has
>>> a length.
>>> If you passed in $(document.myform) and myform had 3 elements,
>>> jQuery.length
>>> would be 3 instead of 1.
>>>
>>> The intent was to allow collections like form.elements to pass in
>>> lists of
>>> nodes but still let you pass in the form element if you wanted to
>>> refer to
>>> just the form element. IE is spoiling that.
>>>
>>>
>>>
>>> _______________________________________________
>>> jQuery mailing list
>>> [email protected]
>>> http://jquery.com/discuss/
>>>
>>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/