I'm looking for a cleaner way to do this:
<script>
$.extend($.fn.validatebox.defaults.rules, {
pickonemore: {
validator: function(value,param){
var hasone = false;
$(param).each(function(k,p) {
if ($(p).val() != "") hasone = true;
});
if(hasone) {
$(param).each(function(k,p) {
$(p).validatebox('disableValidation');
});
} else {
$(param).each(function(k,p) {
$(p).validatebox('enableValidation');
});
}
return hasone;
},
message: 'Enter at least one value in this group.'
}
});
</script>
<input id="box1" class="easyui-validatebox" type="text" name="box1" required="required" validType="pickonemore['#box1','#box2','#box3']"></input></td>
<input id="box2" class="easyui-validatebox" type="text" name="box2" required="required" validType="pickonemore['#box1','#box2','#box3']"></input></td>
<input id="box3" class="easyui-validatebox" type="text" name="box3" required="required" validType="pickonemore['#box1','#box2','#box3']"></input></td>
goal is to require one or more of the 3 values to be entered. I'm using enableValidation/disableValidation calls because my new validator does not seemed to be called when a box is blank. is there a better way?