Aessandro
Aessandro

Reputation: 5771

Foundation Abide for two selects

I have the following HTML:

    <div class="large-4 columns genderSection">
       {#  <div class="left label"><h3>{{ 'PEOPLE'|trans }}</h3><sub class="asterisk">*</sub></div> #}
        <div class="row">
            <div class="large-4 columns selection">
                <p>Total number of:</p>
            </div>
            <div class="large-4 columns maleDropDown">
                <label>{{ 'MALE'|trans }}</label>
                <select class="sel-box" required>
                    <option value="" selected="selected"></option>
                    <option value="01">01</option>
                    <option value="02">02</option>
                </select>
                <input class="hide" data-highlight-code="2090" id="males" name="numberOfMales" tabindex="17" type="text" value="0" autocomplete="off" />
            </div>
            <div class="large-4 columns femaleDropDown">
                <label>{{ 'FEMALE'|trans }}</label>
                <select class="sel-box" required>
                    <option value="" selected="selected"></option>
                    <option value="01">01</option>
                    <option value="02">02</option>
                </select>
                <input class="hide" data-highlight-code="2090" id="females" name="numberOfFemales" tabindex="17" type="text" value="0" autocomplete="off" />
            </div>
        </div>
    </div>

It works fine, however, when I click on submit for the form, the 2 selects don't get validated unless I focus on them then the validation gets triggered.

As far as I know the "require" attribute should be enough to trigger the validation for each input or select.

IF you have 2 selects do you need to distinguish them somehow?

Upvotes: 3

Views: 301

Answers (1)

ashkufaraz
ashkufaraz

Reputation: 5307

use jquery for validation

http://jsfiddle.net/tPRNd/506/

$(document).ready(function () {

$('#myform').validate({ // initialize the plugin
    rules: {
        year: {
            selectcheck: true
        },
        month: {
            selectcheck: true
        }
    },
    submitHandler: function (form) { // for demo
        alert('valid form submitted'); // for demo
        return false; // for demo
    }
});

jQuery.validator.addMethod('selectcheck', function (value) {
    return (value != '0');
}, " required");

});

Upvotes: 0

Related Questions