/***********add custome validation for check box at least one check box checked*************/
$.validator.addMethod('require-one', function(value) {
return $('.require-one:checked').size() > 0;
}, 'Please check at least one property feature.');
var checkboxes = $('.require-one');
var checkbox_names = $.map(checkboxes, function(e, i) {
return $(e).attr("name")
}).join(" ");
$('#Addpropertyform').validate({
ignore: ".ignore",
groups: {
checks: checkbox_names
},
errorPlacement: function(error, element) {
if (element.attr("type") == "checkbox") error.insertAfter(checkboxes.last());
else error.insertAfter(element);
},
invalidHandler: function(e, validator){
if(validator.errorList.length)
$('#tabs a[href="#' + $(validator.errorList[0].element).closest(".tab-pane").attr('id') + '"]').tab('show')
}
});
$.validator.addMethod('require-one', function(value) {
return $('.require-one:checked').size() > 0;
}, 'Please check at least one property feature.');
var checkboxes = $('.require-one');
var checkbox_names = $.map(checkboxes, function(e, i) {
return $(e).attr("name")
}).join(" ");
$('#Addpropertyform').validate({
ignore: ".ignore",
groups: {
checks: checkbox_names
},
errorPlacement: function(error, element) {
if (element.attr("type") == "checkbox") error.insertAfter(checkboxes.last());
else error.insertAfter(element);
},
invalidHandler: function(e, validator){
if(validator.errorList.length)
$('#tabs a[href="#' + $(validator.errorList[0].element).closest(".tab-pane").attr('id') + '"]').tab('show')
}
});
No comments:
Post a Comment