Need some advice on approach to form validation

I’m in need of some advice for how to approach form validation. I’ve been reading the Novice to Ninja book, but I’m more novice.

I have a form comprised of 8 fieldsets that contain (first, last, email, dept, mail stop). I need to create rules to meet the following specification.

  • A valid team nomination is 2 or more individuals.
  • A team nomination may include up to 8 individuals.
  • All fields for each individual are required. e.g., you touch the first field for #3, all fields for #3 is required (first, last, email, mail stop, dept).

Is it better to write conditional statements for each set of fields looking for val().length != 0 and build up an error message or is there a more efficient method using form validation plugin rules?



The first thing you need to do is to ensure that your server-side script (PHP, ASP, .NET, etc) performs the above validation with the submitted form.

Why? JavaScript is optional so you need to first be prepared for when your script is not used.