Before praying: dress, place and intention
For a prayer to be valid, six things must be in place: being in a state of purity (ablution), having a clean body, clothes and place, covering what must be covered, the prayer time having begun, facing the qiblah, and having the intention in the heart.
One may pray anywhere the ground is clean: at home, at work, outdoors. A rug is not required. The intention is not spoken: it is enough to know which prayer one is about to perform.
conditions.jpg۞يَٰبَنِيٓ ءَادَمَ خُذُواْ زِينَتَكُمۡ عِندَ كُلِّ مَسۡجِدٖ وَكُلُواْ وَٱشۡرَبُواْ وَلَا تُسۡرِفُوٓاْۚ إِنَّهُۥ لَا يُحِبُّ ٱلۡمُسۡرِفِينَ﴿٣١﴾
O children of Adam, take your adornment at every masjid, and eat and drink, but be not excessive. Indeed, He likes not those who commit excess
The reference text
«لاَ يُصَلِّي أَحَدُكُمْ فِي الثَّوْبِ الْوَاحِدِ، لَيْسَ عَلَى عَاتِقَيْهِ شَىْءٌ»
“Let none of you pray in a single garment with nothing over his shoulders.”
Sahih al-Bukhari 359 · Read on sunnah.com
«لاَ يَقْبَلُ اللَّهُ صَلاَةَ حَائِضٍ إِلاَّ بِخِمَارٍ»
“Allah does not accept the prayer of a woman who has reached puberty unless she wears a head-covering (khimar).”
Sunan Abi Dawud 641 · Read on sunnah.com
What invalidates the prayer
Agreed by all
Losing one's ablution, speaking deliberately, laughing out loud, eating or drinking, turning completely away from the qiblah, deliberately uncovering what must be covered, or deliberately omitting a pillar (such as a bowing).
In case of forgetfulness
If one forgets an action, adds one, or doubts the number of rak'at, one builds on what is certain and performs two prostrations of forgetfulness (sujud as-sahw) at the end of the prayer (al-Bukhari 1224; Muslim 571). Their place, before or after the final salutation, varies between schools.
Sources: Sahîh al-Bukhârî 359, 1224 ; Sahîh Muslim 571 ; Sunan Abî Dâwûd 641 ; Ibn Qudâma, al-Mughnî, bâb sitr al-'awra ; An-Nawawî, al-Majmû', bâb sitr al-'awra ; Ibn 'Âbidîn, Radd al-muhtâr, shurût as-salât