Riyad as-SalihinChapter 17Hadith 1016
Full Sharh — Riyad as-Salihin 1016
وعن أنس رضي الله عنه أن رسول الله صلى الله عليه وسلم قال: "إن هذه المساجد لا تصلح لشيء من البول ولا القذر، إنما هي لذكر الله تعالى، وقراءة القرآن" أو كما قال رسول الله صلى الله عليه وسلم . ((رواه مسلم)).
English Translation
Anas (May Allah be pleased with him) said:: The Messenger of Allah (ﷺ) said, "It is not proper to use the mosque for urinating or easing oneself. They are merely built for the remembrance of Allah and the recitation of the Qur'an", or as he stated..
Source
Riyad as-Salihin(رياض الصالحين)
The Book of the Prohibited actions
Hadith Number
1016