I have two fields, field1 is a checkbox and field2 is a normal text field. I want to hide a field2 if a field1 is not checked and if 

field1 is checked then show field2. For that, I am creating the following code: 

```

odoo.define('survey_inherit.FormView', function (require) {
"use strict";

var FormView = require('web.FormView');
var core = require('web.core');
var QWeb = core.qweb;

var FormView = FormView.extend({
   _checkField: function(){

        var $checkbox = $('.custom-control-input').val();

        if ($checkbox.is(':checked')) {

        $('.o_form_label').show();
        $('.mandatory_msg_class').show();
        }else{

          $('.mandatory_msg_class').hide();
        }//close else
   },
});//close FormController

return FormView; 
});

```

But field2 is not hidden if field1 is not checked and also field2 is not shown if field1 is checked.

**Update**

My requirement is that I have one form which contains a one2many field with widget many2many\_tags and other fields. After clicking on tags of many2many\_tags, I want to display the complete records in other fields. I am able to get complete records after a click on tags and also these records are able to put in other fields. After using attrs and opening form view for creating records field2 will never display. But open form view in edit mode after creating a record and click on many2many\_tags 
field2 is not displayed because of attrs.
Removing attrs and opening form view for creating records field will display(but don't want to display because field1 is not checked) and open form view in edit mode after creating a record, click on many2many\_tags work fine as expected.
Attrs condition: attrs=**"{'invisible':[('constr\_mandatory','!=',True)]}"**
constr\_ mandatory: checkbox field  

This is the reason I am not using attrs and trying to achieve with the help of javascript. I hope the provided information is understood. Also, I have updated the question added screenshots for better understanding.

Using attrs:[![enter image description here](https://i.stack.imgur.com/heUMU.png)](https://i.stack.imgur.com/heUMU.png)

Using attrs click on many2many\_tags
[![enter image description here](https://i.stack.imgur.com/Au10q.png)](https://i.stack.imgur.com/Au10q.png)

Without using attrs:
[![enter image description here](https://i.stack.imgur.com/Ahsci.png)](https://i.stack.imgur.com/Ahsci.png)