أَخْبَرَنَا عُتْبَةُ بْنُ عَبْدِ اللَّهِ، قَالَ قُرِئَ عَلَى مَالِكٍ وَأَنَا أَسْمَعُ، عَنْ أَبِي النَّضْرِ، عَنْ سُلَيْمَانَ بْنِ يَسَارٍ، عَنِ الْمِقْدَادِ بْنِ الأَسْوَدِ، عَنْ عَلِيِّ بْنِ أَبِي طَالِبٍ، رضى الله عنه أَمَرَهُ أَنْ يَسْأَلَ رَسُولَ اللَّهِ صلى الله عليه وسلم عَنِ الرَّجُلِ إِذَا دَنَا مِنَ الْمَرْأَةِ فَخَرَجَ مِنْهُ الْمَذْىُ فَإِنَّ عِنْدِي ابْنَتَهُ وَأَنَا أَسْتَحْيِي أَنْ أَسْأَلَهُ ‏.‏ فَسَأَلَ رَسُولَ اللَّهِ صلى الله عليه وسلم عَنْ ذَلِكَ فَقَالَ ‏"‏ إِذَا وَجَدَ أَحَدُكُمْ ذَلِكَ فَلْيَنْضَحْ فَرْجَهُ وَلْيَتَوَضَّأْ وُضُوءَهُ لِلصَّلاَةِ ‏"‏ ‏.‏

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 (PBUH) 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 (PBUH) 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." Translation Not Available

Book Ref: Sunan An Nisai Book 4 Hadith 440
Web Ref:  Sunan An Nisai Vol 1 Book 4 Hadith 441