I am using the jquery validation plugin: jQuery validation. Now, I have this snippet with a simple validation method which is used to verify the number of checked checkboxes based on a given parameter
$.validator.methods.cbMinRequired = function (value, element, param) {
return $(element).parent().find(":checked").length >= param;
};
$(function () {
// validate the comment form when it is submitted
$("#myform").validate({
keyup: true,
keypress: true,
click: true,
change: true,
debug: true,
errorClass: "invalid",
rules: {
mycheckboxes: {
cbMinRequired: 1
}
}
});
});
Check out my Fiddle: jsFiddle checkbox vaidation example
As you can see, I have a problem.
I have to validate the form by triggering "submit" first. But I want to validate it after load. There is no option to trigger the submit initially as I think, since at the end I want to trigger a 'save action' with this button which shouldn't be invoked after page load.
Any kind of ideas how to cope with this?