The One Direction star donated his locks to charity.