Only apply the CSS class "mandatory" if a field is empty (follow up on #4730)