Mandatory custom fields

Mandatory custom fields

Under preferences we made a new custom field for Invoices. Is there a way to make it mandatory?
If not, can you suggest a workaround? e.g. custom function that aborts saving if the field is empty?
thank you for your help!
Umberto