Have you used the form conditions in the form builder? See this documentation
- Open the Forms application.
- Edit () a form.
- Switch to the Form builder tab.
- Click on the field whose visibility condition you wish to configure.
-
On the properties panel, switch to the Visibility tab.
- Select from the available options:
- Always – the field is always visible. This is the default state for all fields.
- Never – the field is always hidden. Useful if you need to remove a field from the form but want to keep its associated data stored in the system.*
For something more custom try this documentation