How to make data field unchangable for user?

How to make data field unchangable for user?

Some data fields I have scripted to calculate themselves automatically(using different dates), using different date. I am using script like this: 
  1. if input.main_date != null
  2. {
  3.       input.purchase_date = input.main_date.subweek(2);
  4. }

What I would like to achieve is to disable those data fields from being edited by the user. So for data fields that are calculated automatically using the script above, I would like to make them non-editable by user (so only automation affects them). Is this possible? Thanks!