Mootools Form.Validator checkbox

245 views
Skip to first unread message

electronbender

unread,
Dec 16, 2011, 4:27:58 AM12/16/11
to Clientcide
I want to validate a checkbox. Actually multiple ones with one and
same name:

<input type="checkbox" name="somefield" value="1">1
<input type="checkbox" name="somefield" value="2">2
<input type="checkbox" name="somefield" value="3">3
I want to make sure at least one box is checked before the form is
submitted.

So i've added a validator:

Form.Validator.add('isChecked', {
errorMsg: 'One of these fields is required',
test: function(element){
if (element.type == 'checkbox' || element.checked==true)
return false;
else return true;
}
});
But that requires all fields to be checked...

In the least case i want to pop out the same Form.Validator.Tips error
message (cant figure out how that is fired)...

So how do i go about dealing with this?

Aaron Newton

unread,
Dec 16, 2011, 4:32:17 AM12/16/11
to clien...@googlegroups.com
1) general questions about MooTools should go to the MT users mailing list, not to Clientcide. Your answer a) may already be there (always search first!) and b) will help others if not.


--
You received this message because you are subscribed to the Google Groups "Clientcide" group.
To post to this group, send email to clien...@googlegroups.com.
To unsubscribe from this group, send email to clientside+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clientside?hl=en.


electronbender

unread,
Dec 16, 2011, 4:40:44 AM12/16/11
to Clientcide
Doh!

On Dec 16, 10:32 am, Aaron Newton <anut...@gmail.com> wrote:
> 1) general questions about MooTools should go to the MT users mailing list,
> not to Clientcide. Your answer a) may already be there (always search
> first!) and b) will help others if not.
>

> 2) your answer:http://mootools.net/docs/more/Forms/Form.Validator.Extras#Validators:...


>
> On Fri, Dec 16, 2011 at 1:27 AM, electronbender

> <ognen.plavev...@gmail.com>wrote:

Reply all
Reply to author
Forward
0 new messages