Answered by Shaykh Yusuf Weltch
Question
What should a person do if he has romantic or sexual thoughts while fasting? Is he required to take ghusl and continue fasting, or does he have to make up for the day?
Answer
In the Name of Allah, the Most Merciful and Compassionate
Merely having a sexual thought does not affect the validity of the fast and does not require a ritual bath (ghusl). [Maydani, al-Lubab fi Sharh al-Kitab]
However, if because of the thought one ejaculated, the ritual bath becomes obligatory; in this case, the fast still continues, as long as one did not physically cause the ejaculation by an action, such as touching. Such an issue is similar to having a nocturnal ejaculation during Ramadan: the fast remains intact. [Ibid.]
Hope this helps
Allah knows best
[Shaykh] Yusuf Weltch
Checked and Approved by Shaykh Faraz Rabbani