It is completely legal. First, if you did not have an employment contract, you were an employee at will, and could therefore be fired at any time, for any reason whatsover. Second, an employee may be fired for cause for not following instructions or directions--and you said you did not change your hair upon instruction to do so. Third, it is legal for employers to have--and to change at will--policy or standards for grooming, dress, hair style, body art, etc., and fire anyone who does not comply.