[jQuery] Re: (Validation) How to use with Multi-Select?

2009-08-27 Thread Psyclo

Thanks for responding so quickly.
Unfortunately, my form just isn't working like yours.  I don't see
what I've done wrong.  Maybe you can see something?

Here is the code:








Select a person
First Person
Second Person
Third Person





$.validator.addClassRules({
multirequired: {
required: true,
minlength: 1
}
});

$.validator.addMethod("allOrNothing", function(value, element) {
var i, sply, prod, prog, amt, allthere;
allthere = new Array();
for (i=0; document.getElementById('SPLY_'+i)!=null; i++)
{
allthere[i] = -1;
sply = document.getElementById('SPLY_'+i).value;
prod = document.getElementById('prod_'+i).value;
prog = document.getElementById('prog_'+i).value;
amt  = document.getElementById('amt_'+i).value;
if (sply>0 || prod>0 || prog>0 || amt.length>0)
allthere[i] = (sply>0 && prod>0 && prog>0 && 
amt.length>0);
}
return (element.id=='amt0'?element.length>0:element.value>0) ||
allthere[0];
}, "
Data Missing"); $.validator.addClassRules({ allOrNothing: { allOrNothing: true } }); form = $("#briefform") form.validate({ debug: true, success: "valid", submitHandler: function() { alert("Submitted!") }, errorPlacement: function(error, element) { tid = element.attr("id"); for (i=0; document.getElementById('SPLY_'+i)!=null; i++) if (tid == "SPLY_"+i || tid == "prod_"+i || tid == "prog_"+i || tid == "amt_"+i) error.insertAfter("#DESC_"+i); else error.insertAfter(element); }, errorClass: "errormsg" }); On Aug 27, 8:09 am, Jörn Zaefferer wrote: > Here are examples with > multi-selects:http://jquery.bassistance.de/validate/demo/radio-checkbox-select-demo... > > Jörn > > > > On Thu, Aug 27, 2009 at 3:04 PM, Psyclo wrote: > > > I have a form with a multi-select field that needs to be validated, so > > at least one option is selected.  Is there a setting I'm missing in > > the validation plug-in? > > > Thanks in advance.- Hide quoted text - > > - Show quoted text -

[jQuery] Re: (Validation) How to use with Multi-Select?

2009-08-27 Thread Jörn Zaefferer

Here are examples with multi-selects:
http://jquery.bassistance.de/validate/demo/radio-checkbox-select-demo.html

Jörn

On Thu, Aug 27, 2009 at 3:04 PM, Psyclo wrote:
>
> I have a form with a multi-select field that needs to be validated, so
> at least one option is selected.  Is there a setting I'm missing in
> the validation plug-in?
>
> Thanks in advance.
>