Basis Guess two choices
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>
This works great, however when I click on submit for the form, the 2 selects are not checked, if I don't focus on them then the check gets activated.
As far as I know, the "require" attribute should be sufficient to trigger validation for each entry or selection.
IF you have 2 choices, do you need to differentiate them somehow?
+3
source to share
1 answer
use jquery to check
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");
});
0
source to share