I pray regularly, but sometimes my mind gets distracted. Does this invalidate my prayer, even though I avoid past sins? What factors determine the validity or invalidity of a prayer?
When your mind gets distracted from your Prayers, it does not invalidate your Prayer though it is not the good situation of Prayers.
Your Prayers are valid as far as your Wudhu is valid and your body and clothes are Tahir (pure) and you perform all the obligatory acts of Salah.
It is very good to keep your mind in your Prayers but if your mind gets distracted, your Salah remains valid.
Wassalam