Reference: Sharh ‘Umdatil-Fiqh – Tape No.9, Question No.34
Question: If a man was in a state of major ritual impurity (janaabah), and began praying having forgotten he was in a state of janaabah, and then remembered whilst he was in prayer, what should he [now] do?
Response: He should [stop praying,] go and have a bath [or shower], and then [return to] pray. Even if he does not remember [he is in a state of janaabah] until after he has finished, then his prayer is invalid, and he is required to have a bath [or shower] and then repeat the prayer.