How to validate 3 or more fields when creating content in D7 I have a custom content type with 3 fields (integer). How can I check when content is created or edited that the sum of those three fields are equal to a predefined total. For instance, if the three fields represent percentages of a task to be completed, I would like to issue an error message if the sum of the three fields is not 100%
Create a module to add a validation handler to the form by implementing hook_form_alter():

function MODULE_form_alter(&amp;$form, &amp;$form_state, $form_id) {
  if ($form_id == 'MY_FORM_ID') {
    $form['#validate'][] = '_MODULE_validate';
  }
}


Then define the handler function that checks the field values:

function _MODULE_validate($form, &amp;$form_state) {
  // Check that the sum of the fields equals a predefined total
}


If you're not familiar with creating your own modules, but are comfortable with PHP, you could probably use the Field Validation module to add a custom PHP validator that does the same thing.