gpt4 book ai didi

css - 基金会遵守两个选择

转载 作者:行者123 更新时间:2023-12-04 16:03:11 28 4
gpt4 key购买 nike

我有以下 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 个选择不会得到验证,除非我关注它们然后触发验证。

据我所知,“require”属性应该足以触发每个输入或选择的验证。

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

最佳答案

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

});

关于css - 基金会遵守两个选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27192172/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com