If $(X,d_1)$ and $(X,d_2)$ two connected metric spaces if only if $X\times Y$ is connected metric space

$(X,d_1)$ and $(X,d_2)$ are two connected metric spaces if and only if $X\times Y$ is a connected metric space with metric $$D((x_1,y_2), (x_2,y_2)) = \max(d_1(x_1,x_2),d_2(y_1,y_2)).$$

I know that product of two connected space is connected but how I have to use their metrics.

• The metric is a red herring, this is true for spaces with no metric. What definition of connected are you using? – Matt Samuel Feb 7 '16 at 1:38
• Oops: you mean $(Y, d_2)$, not $(X, d_2)$, in both the title and question body. – BrianO Feb 7 '16 at 2:19

This is true for any two topological spaces $X$ and $Y$, not necessarily metric spaces.
Let $p_1:X\times Y\to X$ and $p_2:X\times Y\to Y$ be the projections onto first and second coordinate respectively. Then since $p_1$ and $p_2$ are continuous and image of a connected set under a continuous map is connected, you are done.