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:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript" src="/jquery/jquery-1.3.2.min.js"></
script>
<script type="text/javascript" src="/jquery/jquery.validate.js"></
script>
<form name="brief" id="briefform" enctype="multipart/form-data"
action="/amstest/edit.php" method="POST">
<select name=ROLE_1 id=ROLE_1 validate="required:true, minlength:1"
multiple="multiple" title="Please specify at least one person"
size="5">
<option value=''>Select a person
<option value="1">First Person
<option value="2">Second Person
<option value="3">Third Person
</select>
<input type="submit" value="Validate Selecttests"/>
</form>

<script language="JavaScript" type="text/javascript">
        $.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];
        }, "<br>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"
        });
</script>
</body>
</html>

On Aug 27, 8:09 am, Jörn Zaefferer <joern.zaeffe...@googlemail.com>
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<m...@datamodel.org> 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 -

Reply via email to