It is narrated from Hazrat Abu Huraira (may Allah be pleased with him) that the Holy Prophet (peace and blessings of Allah be upon him) said: When any of you feels the need to urinate or defecate, he should not stand for prayer.
Hadith Referenceمسند احمد / مسند المكثرين من الصحابة / 9697
Hadith Gradingحکم دارالسلام:حديث صحيح بطرقه وشواهده، وهذا إسناد ضعيف لضعف داود