It was narrated from Al-Miqdad bin Al-Aswad thatt 'Ali bin Abi Talib, peace be upon him, told him to ask the Messenger of Allah (ﷺ) about a man who gets close to a woman and Madhi comes out of him. (He said: ) For his daughter is (married) to me and I feel too shy to ask him. So he asked the Messenger of Allah (ﷺ) about that and he said: If any one of you notices that let him sprinkle water on his private parts and perform Wudu' as for prayer.
Authentic