Answered by Shaykh Faraz Rabbani
In regards to my previous e-mail on intention:
a) If one resolves to pray ‘asr without resolving on how many rak’ats will performing or whether it is fard or not, will his salah be, insha’Allah, valid?
In the name of Allah, the inspirer of truth,
It is not necessary to specify the number of rakats for one’s prayer to be valid, because the number of rakats for the obligatory prayers is fixed.
Even if one mistakenly intended a wrong number of rakats, one’s prayer would be valid.
It is recommended, however, to intend the number of rakats. [Ibn Abidin, Radd al-Muhtar]
For fard and wajib prayers, it is necessary to specify (in one’s heart) which prayer one is performing (e.g. fard of Asr, or the Asr prayer, knowing that it is the fard).
In non-obligatory prayers, a general intention to pray is sufficient, though it is best to specify what one is praying, especially in the sunna prayers (e.g. the sunna of zuhr). [Ibn Abidin, ibid.]
And Allah alone gives success.