Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8156973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T17:07:23+00:00 2026-06-06T17:07:23+00:00

Trying to figure out why my recipient multiselect isn’t validating on form submission. Should

  • 0

Trying to figure out why my recipient multiselect isn’t validating on form submission. Should be atleast 1 person chosen. I have it set to be required true but yet its still not displaying the error.

http://jsfiddle.net/mMZYT/

JS:

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('');  
                }
            }
        });
    }
});

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T17:07:24+00:00Added an answer on June 6, 2026 at 5:07 pm

    You can use the following code to validate the single selection required.

    The magic happens in this line:

    ignore: ':hidden:not("#mySelect")'
    

    It’s necessary because as default jQuery Validate ignores hidden fields…

    HTML

    <form action="some/action" id="myForm" method="POST">
    
        Select: <select class="someSelect" name="mySelect" id="mySelect" multiple="multiple">
            <option value="some_val1">Some Value</option>
            <option value="some_val2">Some Other Value</option>
        </select>
    
        <input type="submit" value="Submit" />
    
    </form>
    

    Javascript/jQuery

    $(document).ready(function() {
        $('#mySelect').multiselect({
            noneSelectedText: 'Select Something (required)',
            selectedList: 3,
            classes: 'my-select'
        });
    
        $.validator.addMethod("needsSelection", function(value, element) {
            return $(element).multiselect("getChecked").length > 0;
        });
    
        $.validator.messages.needsSelection = 'You gotta pick something.';
    
        $('#myForm').validate({
        rules: {
            mySelect: "required needsSelection",
            input1: "required isPercent",
            input2: "required",
            input3: "required"
        },
        ignore: ':hidden:not("#mySelect")', // Tells the validator to check the hidden select
        errorClass: 'invalid'
        });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to figure out the best way to do this: Should I do something
I have a problem and Google hasn't helped me much. I'm trying figure out
Trying to figure out the best way to accomplish this. I have inhereted a
I'm learning rails and I'm trying to figure out database associations. If I have
Trying to figure out the best way to have a templated brochure that creates
Trying to figure out how to convert how to covert 5 variables I have
trying to figure out why this is happening - I have an input text
Trying to figure out a regex for validating a network path ie: \\comp\xyz or
Trying to figure out out how to overload parenthesis on a class. I have
I have got myself into a bit of a mess trying figure out the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.