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