Mehrfachauswahl mit JQuery-Validierungs-Plugin validieren
Ich versuche herauszufinden, warum meine Empfänger-Mehrfachauswahl beim Absenden des Formulars nicht gültig ist. Sollte mindestens 1 Person gewählt werden. Ich habe es als erforderlich eingestuft, aber es zeigt den Fehler immer noch nicht an.
JS:
<code>var validateform = $("#pmForm").validate({ rules: { recipient: { required: true }, bcc: { required: true }, subject: { required: true }, message: { required: true } }, invalidHandler: function(form, validator) { var errors = validator.numberOfInvalids(); if (errors) { var message = errors == 1 ? 'You missed 1 field. It has been highlighted.' : 'You missed ' + errors + ' fields. They have been highlighted.'; $('.box .content-form').removeAlertBoxes(); $('.box .content-form').alertBox(message, {type: 'warning', icon: true, noMargin: false}); $('.box .content-form .alert').css({ width: '', margin: '0', borderLeft: 'none', borderRight: 'none', borderRadius: 0 }); } else { $('.box .content-form').removeAlertBoxes(); } }, showErrors : function(errorMap, errorList) { this.defaultShowErrors(); var self = this; $.each(errorList, function() { var $input = $(this.element); var $label = $input.parent().find('label.error').hide(); $label.addClass('red'); $label.css('width', ''); $input.trigger('labeled'); $label.fadeIn(); }); }, submitHandler: function(form) { var dataString = $('#pmForm').serialize(); $.ajax({ type: 'POST', url: 'http://www.kansasoutlawwrestling.com/kowmanager/pmsystem/pmsubmit', data: dataString, dataType: 'json', success: function(data) { if (data.error) { $('.box .content').removeAlertBoxes(); $('.box .content').alertBox(data.message, {type: 'warning', icon: true, noMargin: false}); $('.box .content .alert').css({ width: '', margin: '0', borderLeft: 'none', borderRight: 'none', borderRadius: 0 }); } else { $('.box .content').removeAlertBoxes(); $('.box .content').alertBox(data.message, {type: 'success', icon: true, noMargin: false}); $('.box .content .alert').css({ width: '', margin: '0', borderLeft: 'none', borderRight: 'none', borderRadius: 0 }); $(':input','#pmForm') .not(':submit, :button, :hidden, :reset') .val(''); } } }); } }); </code>
Irgendwelche Ideen?