jQuery Validate and depends

I am using jQuery validate to validate a form.  I have mulitple fields that are required if a select box is a certain value.
do i have to do this (see code)
employee_firstname: {
						required: {
							depends: function(element){
									return true;
								} else {
									return false;	

Open in new window

for eac of the dependent fileds or is there a way to say all these other fields are required if the select is a certain value
Who is Participating?
Justin MathewsConnect With a Mentor Commented:
If you want to apply the same rule for multiple elements with names starting with, say, "employee" you can add this code to your $(document).ready() function:
	$(this).rules("add", {
		required: {
		depends: function(elem){$("#person_responsible").val()=='6';}},
		messages: {
			required: "This field is required"
	} );			

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.