Sample Trigger:
trigger AccountTrigger on Account ( before update ) {
for ( Account objAcc : trigger.new ) {
Account objAccWithPriorValues = trigger.oldMap.get( objAcc.Id );
if ( objAcc.Name != objAccWithPriorValues.Name ) {
objAcc.Name.addError( 'Account Name cannot be changed' );
}
}
}
Output: