If a woman lengthens her garment by a handspan, it will lead to the garment getting dirty, so how can she pray in it?
Question

My question is referring to an answer which said that the Prophet (saw) allowed women for thir jilbaabs to trail on the floor as so to cover their bodies completely, but if we were to do this would this not collect the dirt and filth that may be present on the ground, therefore if we were to pray would this nullify the prayer?.
Praise be to Allah.The society of the Sahaabah (may Allah be pleased with them all) was extremely keen to protect women and cover their ‘awrahs, and a woman is all ‘awrah, as the Prophet (peace and blessings of Allah be upon him) said. So when a woman goes out she should cover her entire body, even her feet. Hence they used to make a “tail” i.e., a woman would make her garment long so that it would be like a tail behind her, so that nothing of her body would show. 
Shaykh al-Islam Ibn Taymiyah said: This is what they did when they went outside the house. But inside the house they did not wear that."(Majmoo’ al-Fatawa, 22/119)
What you have said – may Allah guide you – about her garment getting dirty, is as nothing in comparison with the idea of protecting women and closing the door to evil and fitnah (temptation) in society. 
You should note that the basic principle is that women should stay in their houses, as Allah says (interpretation of the meaning): 
“And stay in your houses” [Al-Ahzaab 33:33]
So women should not go out unless it is necessary. 
With regard to what you mention about the clothes getting dirty, and that some impurity (najaasah) may get into them, that is possible. This question was raised at the time of the Prophet (peace and blessings of Allah be upon him). It was narrated that the umm walad [a concubine who had borne a child to her master] of Ibraaheem ibn ‘Abd al-Rahmaan ibn ‘Awf said: I used to drag my ‘tail’ (i.e., let my garment drag along the ground) and I would pass through filthy places and clean places. Umm Salamah entered upon me and I asked her about that, and she said: I heard the Messenger of Allah (peace and blessings of Allah be upon him) say: “What comes after it purifies it.” (Narrated by Imam Ahmad, 25949; al-Tirmidhi, 143; Ibn Maajah, 531. Classed as saheeh by al-Albani. See Saheeh Abi Dawood, 369). 
See al-Muntaqi Sharh al-Muwatta’ by al-Baaji, 1/65 
And Allah knows best.