Here an input field validation-function is used on the 'Favourite meat' field. That field is only required if 'Veggie' is unchecked.
Again validation is performed first in the browser and again on the server using the same javascript code.