If a person has an erotic dream then when he wakes up he does not see any trace of semen on his clothes, then he does not have to do ghusl.
Ibn Qudaamah said in al-Mughni:
If a person thinks that he had an erotic dream, but he did not see any semen, then he does not have to go ghusl. Ibn al-Mundhir said: Every scholar from whom I acquired knowledge is agreed on this.
Umm Salamah narrated that Umm Sulaym said: “O Messenger of Allaah, does a woman have to do ghusl if she has an erotic dream?” He said: “Yes, if she sees water.” Agreed upon. This indicates that she does not have to do ghusl if she does not see water (discharge).
Fasting is not invalidated if one sees an erotic dream because this is something that the fasting person does not choose to do, it happens involuntarily.
Al-Nawawi said in al-Majmoo’:
If a person sees an erotic dream, that does not invalidate his fast, according to scholarly consensus, because it is involuntary, as in the case where a fly enters his mouth and he swallows it involuntarily. This is what is to be followed in this issue. With regard to the hadeeth narrated from the Prophet (peace and blessings of Allaah be upon him) which says “The one who vomits, has an erotic dream or has cupping done does not break his fast” – this is a weak (da’eef) hadeeth which should not be taken as evidence.
It says in al-Mughni (4/363):
If a person has an erotic dream, that does not invalidate his fast, because that does not happen by his choice. This is akin to if something enters his throat whilst he is sleeping.
Shaykh Ibn Baaz was asked in Majmoo’ al-Fataawa (15/276) about a person who slept during the day in Ramadaan and semen came out of him – does he have to make up this day?
He does not have to make it up, because a wet dream does not happen by his choice, it is involuntary. But he does have to do ghusl if he sees semen.
Shaykh Ibn ‘Uthaymeen was asked in Fataawa al-Siyaam (p. 284) about a person who has an erotic dream during the day in Ramadaan. He replied: His fast is still valid, and if he has an erotic dream that does not invalidate his fast, because it was involuntary. The Pen was lifted from him whilst he was asleep [i.e., his actions are not recorded and he will not be brought to account for them].
It says in Fataawa al-Lajnah al-Daa’imah (10/274):
If a person has an erotic dream whilst he is fasting or in ihraam for Hajj or ‘Umrah, there is no sin on him and he does not have to offer expiation, and that does not invalidate his fast or Hajj or ‘umrah. He has to do ghusl from janaabah if any semen came out.