Looking at a member of the opposite sex with desire is prohibited in Islam. The eye is the key to the feelings, and the look is a messenger of desire. So, a person should beware of lustful desires and must not indulge in them.
However, eye contact between people of the opposite sex cannot be completely avoided as it may be necessary in some situations. So, when there is a valid reason for eye contact, you should be assured that there is no lustful desire behind it.

Sheikh Muhammad Nur Abdullah, former president of the ISNA (Islamic Society of North America) and member of the Fiqh Council of North America, states: First of all, it is forbidden to look lustfully at members of the opposite sex. That is very clear in the words of the Qur’an and the Sunnah of Prophet Muhammad (peace and blessings be upon him).