validate-one-required fails in IE8

3 views
Skip to first unread message

TheIvIaxx

unread,
Jul 2, 2009, 8:58:55 PM7/2/09
to MooTools Users
In IE8 the validate-one-required throws an error. Saying that the
given element(DIV) doesnt have a method called getElements(). in FF
and chrome, it works fine. Not sure how the div element isnt getting
this method.

This does not work:

<form id='form'>
<div>
<input type="checkbox" />
<input id="one" type="checkbox" class="validate-one-required" /
>
</div>
<input type='button' value='x' />
</form>

This does work:

<form id='form'>
<input type="checkbox" />
<input id="one" type="checkbox" class="validate-one-required" />
<input type='button' value='x' />
</form>

So wrapping the checkboxes in a div fails, but thats one of the key
things about validate-one-required :)

Am i missing something with this?

Thanks

nutron

unread,
Jul 2, 2009, 9:18:27 PM7/2/09
to mootool...@googlegroups.com
I've got this fixed (the code was using element.parentNode for some reason, instead of element.getParent()). It'll be in the next release, in the mean time, you can fix it by just adding this to your code (to redefine the validator):

FormValidator.add('validate-one-required', {
errorMsg: FormValidator.getMsg.pass('oneRequired'),
test: function(element, props){
var p = document.id(props['validate-one-required']) || element.getParent();
return p.getElements('input').some(function(el){
if (['checkbox', 'radio'].contains(el.get('type'))) return el.get('checked');
return el.get('value');
});
}
});
The MooTools Tutorial: www.mootorial.com Clientcide: www.clientcide.com


View this message in context: Re: [Moo] validate-one-required fails in IE8
Sent from the MooTools Users mailing list archive at Nabble.com.

theiviaxx

unread,
Jul 3, 2009, 12:29:53 AM7/3/09
to MooTools Users
thank you sir, love this framework :)

On Jul 2, 6:18 pm, nutron <anut...@gmail.com> wrote:
> I've got this fixed (the code was using element.parentNode for some reason,
> instead of element.getParent()). It'll be in the next release, in the mean
> time, you can fix it by just adding this to your code (to redefine the
> validator):
> FormValidator.add('validate-one-required', {
> errorMsg: FormValidator.getMsg.pass('oneRequired'),
> test: function(element, props){
>  var p = document.id(props['validate-one-required']) || element.getParent();
> return p.getElements('input').some(function(el){
>  if (['checkbox', 'radio'].contains(el.get('type'))) return
> el.get('checked');
> return el.get('value');
>  });
>
> }
> });
>
> On Thu, Jul 2, 2009 at 5:59 PM, TheIvIaxx (via Nabble) <
> ml-user+199977-392105...@n2.nabble.com<ml-user%2B199977-392105...@n2.nabble.com>
>
>
>
>
>
> > wrote:
>
> > In IE8 the validate-one-required throws an error.  Saying that the
> > given element(DIV) doesnt have a method called getElements().  in FF
> > and chrome, it works fine.  Not sure how the div element isnt getting
> > this method.
>
> > This does not work:
>
> > <form id='form'>
> >     <div>
> >         <input type="checkbox" />
> >         <input id="one" type="checkbox" class="validate-one-required" /
>
> >     </div>
> >     <input type='button' value='x' />
> > </form>
>
> > This does work:
>
> > <form id='form'>
> >     <input type="checkbox" />
> >     <input id="one" type="checkbox" class="validate-one-required" />
> >     <input type='button' value='x' />
> > </form>
>
> > So wrapping the checkboxes in a div fails, but thats one of the key
> > things about validate-one-required :)
>
> > Am i missing something with this?
>
> > Thanks
>
> > ------------------------------
> >  View message @
> >http://n2.nabble.com/-Moo--validate-one-required-fails-in-IE8-tp31988...
> > To start a new topic under MooTools Users, email
> > ml-node+660466-1583815...@n2.nabble.com<ml-node%2B660466-1583815...@n2.nabble.com>
> > To unsubscribe from MooTools Users, click here< (link removed) >.
>
> -----
> The MooTools Tutorial:  http://www.mootorial.comwww.mootorial.com
> Clientcide:  http://www.clientcide.comwww.clientcide.com
> --
> View this message in context:http://n2.nabble.com/-Moo--validate-one-required-fails-in-IE8-tp31988...
Reply all
Reply to author
Forward
0 new messages