The World Federation One Stop Fiqh

Ruling 790

If someone forgets that his body or clothing is impure and remembers it during or after prayers, in the event that his forgetfulness was due to carelessness and heedlessness, he must, based on obligatory precaution, perform the prayer again. And if the prescribed time for the prayer has expired, he must make it up; otherwise, it is not necessary for him to perform the prayer again. However, if he remembers it [i.e. that his body or clothing is impure] during prayers, he must act according to the instructions that will be mentioned in the next ruling.