Validate: Making multiple elements with the same name all required
I have a form with multiple elements with the same name (this gets treated as an array of values on post). I want them all to be required, but when I submit the form it passes validation if only one of them has a value.
E.g:
- <script type="text/javascript">
- $(document).ready(function() {
- $("form").validate({
- rules: {
- field: "required"
- }
- });
- });
- </script>
- <form>
- <select name="field">
- <option value="">Select...</option>
- <option value="something">Something</option>
- </select>
- <select name="field>
- <option value="">Select...</option>
- <option value="something">Something</option>
- </select>
- <button type="submit">Submit</button>
- </form>
Thanks,
Chris