I am making a form and using jQuery validation plugin
The user has to add at least 1 ‘tag’ to the form before it can be validated. I add the ‘tags’ using a div.
This is my code
$(document).ready(function(){
$("#form").validate({
rules: {
tags: {
required: function(element) {
return ($('.tag').length);
}
},
name: "required",
"checkbox[]": "required",
},
messages: {
tags: "No tags found",
name: "input name!",
"checkbox[]": "select at least 1 category",
}
});
});
It gives the error even if the div exists sadly. Any ideas?
Thanks in advance!
Resin
Seems that I found a way to do it.
I just added an input to my div and refered to it instead, and also i changed
to this