基金会Abide两个选择

时间:2014-11-28 15:52:31

标签: css zurb-foundation abide

我有以下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>

它工作正常,但是,当我点击提交表单时,2选择不会被验证,除非我专注于它们然后验证被触发。

据我所知,&#34;要求&#34;属性应该足以触发每个输入的验证或选择。

如果您有2个选择,您需要以某种方式区分它们吗?

1 个答案:

答案 0 :(得分:0)

使用jquery进行验证

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");

});