This question is most commonly applied to airplanes nowadays. This fatwa is from islamtoday.net and the original can be found here.
This is conditional on the person being able to properly observe all the pillars, obligations and conditions of prayer while riding in the vehicle. Otherwise, the person should wait until he gets out of the vehicle and perform the prayer properly.
However, in a case where the person thinks that the prayer time could elapse before he arrives or before he will be able to leave from the vehicle, then it is permissible for him to perform prayer according to his circumstances.
Some people of knowledge have offered the opinion that if the prayer that the person needs to perform while in a moving vehicle can be combined with the prayer that comes after it (Zuhr with `Asr or Maghrib with `Ishâ’), then the person may combine the prayer with the one after it after departing from the vehicle.
In brief, the person who is forced to pray an obligatory prayer in a moving vehicle has to observe the pillars, obligations and conditions of the prayer to the best of his abilities.
In case he truly cannot do so, such as often is the case with facing the qiblah and standing, then he will be exempted. These things are obligatory when possible and are exempted in cases where they are not possible.
Allah says: “On no soul doth Allah place a burden greater than it can bear.” [Sûrah al-Baqarah: 286]
And says: “Fear Allah as much as you can.” [Sûrah al-Taghâbun: 16]