以下标记效果很好:
<div class="small-8 columns male-female-select">
<div class="row">
<div class="small-6 columns male-select">
<label>{{ 'MALE'|trans }}</label>
<select class="sel-box" data-abide-validator="checkMaleFemale" name="numberOfMales">
<option value="">0</option>
{% for i in 0..data.numberOfGuests %}
<option value="{{ i }}">{{ i }}</option>
{% endfor %}
</select>
</div>
<div class="small-6 columns female-select">
<label>{{ 'FEMALE'|trans }}</label>
<select class="sel-box" data-abide-validator="checkMaleFemale" name="numberOfFemales">
<option value="">0</option>
{% for i in 0..data.numberOfGuests %}
<option value="{{ i }}">{{ i }}</option>
{% endfor %}
</select>
</div>
</div>
</div>
我在abide验证器中有自己的验证:
$(document).foundation({
abide : {
validators: {
checkExpiry: function() {
var expiry = {
month: $('[name="ccExpirationMonth"]').val(),
year: $('[name="ccExpirationYear"]').val()
};
var expiryDate = new Date(expiry.year, expiry.month, 1);
if(expiryDate >= Date.now())
{
return true;
}
return false;
},
checkMaleFemale: function(el, required, parent){
var lastValue = parseInt($('.male-select option:last-child').val()),
warningGroupMax = 'warningGroupMax',
genderWrapper = $('.male-female-select'),
selectedValue = 'data-val',
dropDownMaleFemale = {
value1:0,
value2:0,
checkTotalSelected: function (){
return parseInt(this.value1)+parseInt(this.value2);
},
applyError:function(){
if (this.checkTotalSelected() > lastValue || this.checkTotalSelected() < lastValue){
return false;
}
else if(this.checkTotalSelected() == lastValue){
return true;
}
},
validationCheck:function(){
this.applyError();
}
};
var maleValue = $('[name="numberOfMales"]').val();
dropDownMaleFemale.value1 = maleValue;
//dropDownMaleFemale.validationCheck();
var femaleValue = $('[name="numberOfFemales"]').val();
dropDownMaleFemale.value2 = femaleValue;
return dropDownMaleFemale.applyError();
/*
var maleValue = $('.male-select .selectboxit-text').attr(selectedValue);
dropDownMaleFemale.value1 = maleValue;
//dropDownMaleFemale.validationCheck();
var femaleValue = $('.female-select .selectboxit-text').attr(selectedValue);
dropDownMaleFemale.value2 = femaleValue;
return dropDownMaleFemale.applyError();
*/
}
}
}
});
有没有办法指定从基础应用类错误的位置? 据我所知,它应用于它找到的第一个父项,是否有一种方法可以像jQuery一样指定类似的内容?
element.parent().parent()
由于