Two marriages are not permitted under the Hindu marriage act. However, in response to your question, both marriages are legal. Illegality is determined by its sequence. If a person marries according to Hindu rites and rituals and then contracts another marriage by the court, the court marriage will be null and void, and vice versa.