title: Spring MVC and annotations, how to do a validator in the case of a form that will contain different fields depending of a combo box
body: <p>I am trying to accomplish the following: </p>
  
  <p>I have a form that starts with a combo box, let's say that the user will have to pick either "Student" or "Teacher".</p>
  
  <p>Both "Student" and "Teacher" will have the same fields displayed in the form, but if "Teacher" is checked, I will have more fields being displayed (that are hidden at first and that I will show with jQuery when the user select "Teacher").</p>
  
  <p>The problem is that I want those fields to be mandatory only if "Teacher" is selected.</p>
  
  <p>I have no idea to manage that, I don't think it's gonna be possible using annotations such as:</p>
  
  <pre><code>@NotBlank
  private String teacherCourse;
  </code></pre>
  
  <p>since this field will always be blank when the user will have selected the "Student" radio button.</p>
  
  <p>Any idea? Can I do a custom validation method and how?</p>