Edski73
Edski73

Reputation: 11

Jquery Validate name="name[]" not working

I'm using the Validation plugin from bassistance.de I want to validate the folowing:

<form class="cmxform" id="form1" action="ufm/mailit.php" method="post">
<fieldset>
<input type="checkbox" value="namea" name="name[]" id="namea" /> <label for="namea">Name a</label>
<input type="checkbox" value="nameb" name="name[]" id="nameb" /> <label for="nameb">Name b</label>
<input type="checkbox" value="namec" name="name[]" id="namec" /> <label for="namec">Name c</label>
<button type="submit" id="RegisterButton" name="ButtonValue" value="Aanvragen">Submit</button>
</fieldset>
</form>

And using this javascript:

$(document).ready(function() {
        $("#form1").validate({
            rules: {

                vraag2[]: {required: true, minlength: 1}
                         },

            messages: {
                vraag2[]: "Make at least one choice"
            }
        });
});

But it's not working, It has to do with the [] characters how can I use those characters with the validation plugin?

Thanks!
Edski

Upvotes: 0

Views: 1712

Answers (1)

bobince
bobince

Reputation: 536339

Names in JavaScript object literals must be quoted if they contain non-alphanumerics (or are keywords):

"vraag2[]": "Make at least one choice"

Upvotes: 6

Related Questions