It is stated by Ibn Fairuz (r) in his Hashiyah that writing in small amounts in Salah does not invalidate it. Qadi ‘Abdullah al-‘Anqari (r) also mentions it. Not many Hanbalis explicitly stated this, but it is an important statement. Based on it, our contemporary scholars say that writing a short text in Salah, such as an urgent text that requires little movement, would not invalidate the Salah.
To conclude, a short text on your mobile would not invalidate the prayer, and it is permissible if done for a good reason. There are a few things to note here:
1. There should be a good reason for texting, such as an urgent text to one’s parents.
2. Only little movement is permitted. Taking the phone out of your pocket and writing a brief text is considered little movement, not more than the movement in Salah that is established in the Sunnah.
3. The proof for this ruling is the clear Qiyas. Moving in Salah for a good reason is established in the Sunnah. This is exactly that. Nobody would have a problem if someone took their phone out to silence it or switch off an alarm. Writing a brief urgent text requires no more movement than switching your phone off.