What Invalidates Ghusl?
Question

If my nails are long and not clean, does that invalidate Ghusl? I want to know everything that invalidates Ghusl whilst doing Ghusl; for example, during Ghusl, if water falls on the ground and bounces back onto me, does that invalidate Ghusl?
Praise be to Allah.In order for Ghusl to be valid, there are conditions that must be met, and if they are not met, then Ghusl is invalid. They are:

Intention

The Messenger of Allah (blessings and peace of Allah be upon him) said: “Actions are but by intentions, and each person will have but that which he intended.” (Narrated by Al-Bukhari, 1 and Muslim, 1907)
So it is essential, when beginning to do Ghusl , to have the intention of removing (ritual) impurity (Janabah) by doing that Ghusl.
Shaykh ‘Izz Ad-Din ibn ‘Abd As-Salam (may Allah have mercy on him) said:
“The purpose of intentions is to distinguish acts of worship from ordinary actions, or to distinguish one act of worship from another. There are several examples:
One example is Ghusl, because washing oneself may be done as an act of worship, seeking to draw closer to Allah, such as doing Ghusl to cleanse oneself from (ritual) impurity (Hadath), or it may be done for ordinary purposes, such as cooling off, cleaning oneself, bathing or medicinal purpose, or to remove dirt.
As washing oneself (Ghusl) may be done for various purposes, it is essential to distinguish that which is done for Allah from that which is done for ordinary purposes.” (Qawa`id Al-Ahkam, 1/207)
The Permanent Committee for Academic Research and Ifta’ was asked:
I did Ghusl when I thought I was in a state of purity, therefore I did not intend to remove major impurity. After doing Ghusl, I remembered that I had been in a state of impurity (Janabah) before doing Ghusl. Do I have to repeat Ghusl, or did I purify myself by doing that Ghusl?
They replied: 
“If you did that Ghusl with the intention of cleaning yourself or cooling off, then you must repeat Ghusl with the intention of removing major impurity, because you did not have that intention when you did the first Ghusl, and the Prophet (blessings and peace of Allah be upon him) said: “Actions are but by intentions.” (The Permanent Committee for Academic Research and Ifta’, Salih Al-Fawzan, `Abd Al-`Aziz al Ash-Shaykh, `Abdullah ibn Ghadyan, `Abd Ar-Razzaq `Afifi, `Abd Al-`Aziz ibn `Abdullah ibn Baz, Fatawa Al-Lajnah Ad-Da’imah - vol. 2, 4/133).

The water used for Ghusl must be pure.

Ibn ‘Abd Al-Barr (may Allah have mercy on him) said:
“Any change in the water must be due to something that is impure or something that is not impure. If it is due to something that is impure, then the scholars unanimously agreed that it is not pure and cannot be used for purification.” (At-Tamhid, 19/16)
If someone starts to do Ghusl, then realises that the water is impure, then he must repeat his Ghusl using water that is pure.
With regard to water that splashes off the body of the one who is doing Ghusl, it is still pure.
Ibn Al-Mundhir (may Allah have mercy on him) said:
“The scholars unanimously agreed that in the case of a man who is in a state of impurity, who does not have any impurity on his body, if he pours water on his face or arms, then that water flows onto other parts of his body and his garment, it is still pure, because it is pure water that was in contact with a pure body.…
According to the consensus of the scholars, the water that remains on the limbs of one who has done Wudu or Ghusl, and any drops that fall from him on to his clean garments, is regarded as pure. That is because water that has been used for Wudu or Ghusl is pure.” (Al-Awsat, 1/288)
So if a Muslim does Ghusl with pure water, and the water falls onto clean ground, then the water splashes back onto his body, that does not affect the validity of his Ghusl or the purity of his body.
What usually happens in the kind of bathrooms that are widely used nowadays is that the place for relieving oneself is separate from the place where one does Ghusl, so no contamination occurs, and mere uncertainty about the floor of the bathroom does not count, so as to avoid opening the door to Waswasah [whispers from the devil; intrusive thoughts] or unnecessary caution. So the water that falls on the floor or splashes back onto the body whilst washing oneself is not deemed to be impure, unless one knows that there is any impurity on the floor of the place where one is washing oneself.

The water should reach the entire body , so there should be nothing on the body that can prevent the water from reaching the skin or hair, because Janabah affects the entire body.

An-Nawawi (may Allah have mercy on him) said:
“[The scholars] unanimously agreed that Janabah affects the entire body.” (Al-Majmu`, 1/467)
If there is a surgical dressing, for example, on the skin, or some substance on the hair or skin that forms a barrier that prevents the water from reaching the hair or skin, then in this case Ghusl is not valid and these things must be removed in order for Ghusl to be valid.
In the case of long nails with dirt under them , in most cases they do not prevent the water from reaching under the nail because the water can penetrate it. If it does prevent the water from reaching the skin, then it is a very small area that may be overlooked, because this is something that happens very often to people, and Islamic teaching does not instruct us to make sure that water goes under the nails when doing wudu and Ghusl.
An-Nawawi (may Allah have mercy on him) said:
“If there is dirt under the nails, if it does not prevent the water from reaching what is under the nails because it is a small amount, wudu is valid.
If it does prevent the water from reaching the skin under the nails, then Al-Mutawalli stated that Ghusl is regarded as invalid and the individual is still in a state of impurity (Hadath), as is the case when the dirt is on any other part of the body. In Al-Ihya’, Al-Ghazali stated definitively that it is fine, and Wudu’ and Ghusl are valid in this case, and that it may be overlooked because of necessity. He said: Because the Prophet (blessings and peace of Allah be upon him) used to instruct them to clip their nails and he would criticise leaving any dirt beneath them, but he did not instruct them to repeat the prayer.” (Al-Majmu`, 1/287)
Shaykh Al-Islam Ibn Taymiyah (may Allah have mercy on him) said:
“If a small amount of dirt and the like under the nails prevents water from reaching the skin, the purification is still valid.” (Al-Fatawa Al-Kubra, 5/303)

The fourth condition is a matter concerning which the scholars differed, which is continuity between the parts of Ghusl and not allowing any lengthy interruption between them.

Ibn Qudamah (may Allah have mercy on him) said:
“Most of the scholars do not think that interruption in Ghusl renders it invalid, except Rabi‘ah, who said: If anyone does that deliberately, I think that he must repeat Ghusl. This was the view of Al-Layth, in which he differed from Malik, and some of the companions of Ash-Shafi'i agreed with that.
But the view of the majority is more likely to be correct, because it is Ghusl, in which it is not essential to do the actions in a certain order, so continuity is not required.” (Al-Mughni (1/291-292)
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said in his commentary Zad Al-Mustaqni`:
“What the author’s words appear to mean is that continuity is not essential in Ghusl, so if the individual washes part of his body, then completes it after what would be regarded as a lengthy period according to custom, his Ghusl is still valid. This is our view.
And it was said that continuity is an essential condition. This was narrated from Imam Ahmad, and was the view of some of our companions.
This – i.e., the view that continuity is an essential condition – is more correct, because Ghusl is a single act of worship, the parts of which should follow on from one another in a continuous manner.
But if the individual interrupts it for a valid reason, such as if the water runs out whilst he is doing Ghusl, for example, then he obtains more water after that, he does not have to repeat what he had already washed; rather he should complete what remains to be washed.” (Ash-Sharh Al-Mumti`, 1/365)
So the Muslim should be careful when doing Ghusl, and avoid any lengthy interruption between washing different parts of his body, so as to avoid this matter concerning which the scholars differed, and so as to take precautions to ensure that his prayer is valid.
And Allah knows best.