How to add disabled attribute and remove required attribute to an input text field with javascript with a checkbox onclick action?

I need to update form fields : remove required and turn disabled on
in order to let the user not filling those fields with a chekbox onclick action

i tried to do it myself but i need to be sure how to adress disabled attribute and required attribute to a input text field. I have to understand if i have to put the attribute in the html tag or just play with javascript or jquery