How to Set Read-Only Fields

// executionContext is passed as function parameter
var formContext = executionContext.getFormContext();

// Set field read-only
formContext.getControl("emailaddress").setDisabled(true);

// Set field editable
formContext.getControl("emailaddress").setDisabled(false);

Source: control.setDisabled (Client API reference)