1

I'm using the formwizard plugin and I can't get a checkbox array to validate. I've got other elements on the page working, but can't get this one (not to mention this is one of 2 checkbox arrays I'll need). There must be one or more items selected. I've chopped the page down to what I hope is essential for this question.

<input type="checkbox" name="status_checkbox[]" id="status_professional" value="status_professional">

    <script type="text/javascript">
    $(function(){
        $("#infoForm").formwizard({ 
            formPluginEnabled: true,
            validationEnabled: true,
            validationOptions : {
                rules: {
                    status_checkbox: {
                        //required: "input[name='status_checkbox[]']",
                        required: "input[name='status_checkbox:checked']",
                        minlength: 1
                    },
                },
                messages: {
                    status_checkbox: {
                        required: "Status field is required."
                    },
                }
            },
            focusFirstInput : true,
        });
    });
</script>
1
  • There are 3 different checkboxes. Not sure why only one showed up. The others vary in 'id' and 'value' attributes while having the same 'name'. Commented Dec 6, 2010 at 17:18

1 Answer 1

3

The name needs to be they key you use in the rules, so status_checkbox needs to be status_checkbox[], like this:

$(function(){
    $("#infoForm").formwizard({ 
        formPluginEnabled: true,
        validationEnabled: true,
        validationOptions : {
            rules: {
                "status_checkbox[]": {
                    required: true,
                    minlength: 1
                },
            },
            messages: {
                "status_checkbox[]": {
                    required: "Status field is required."
                },
            }
        },
        focusFirstInput : true,
    });
});
Sign up to request clarification or add additional context in comments.

1 Comment

Yes, thanks! I had tried something close to that except that I didn't put quotes around the property. D'oh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.