To do so you can use Field Conditional States or Conditional Fields modules.
Conditional Fields allows you to manage sets of dependencies between fields. When a field is “dependent”, it will only be available for editing and displayed if the state of the “dependee” field matches the right condition.
When editing a node (or any other entity type that supports fields, like users and categories), the dependent fields are dynamically modified with the States API.
You can, for example, define a custom “Article teaser" field that is shown only if a "Has teaser" checkbox is checked
These dependencies are not only between the fields of the content type but also between the fields of the comment fields as well. As an example
These modules allows you set dependencies among the fields of comments as well, As you can see Comment Dependencies is for doing such thing:
You can also use Field formatter conditions module. This module changes the format of fields in manage display base on conditions of other fields.
Adds conditions to field formatters. Configuration happens on the "Manage Display" screens of every entity type on a per field basis when clicking on the cogwheel on the right.
So by this module you can
- Hide source field when target field is empty.
- Hide source field when target field is not empty.
- Hide source field when current user has specific roles.
- Hide source field on specific pages.
- Hide source field when target field contains a specific string.
- Hide source field when target field doesn't contain a specific string.
- Hide link field if title is empty.
- Hide date field if from/to has expired.