I was recently solving a requirement where a TextBox having text needed to be made read-only, as soon as focus was set on it. This is a typical scenario where a user reloads a form that is to be presented as read-only. This is how I solved the requirement using jQuery:
<input id="Text1" type="text" value="Some Text" />
<input id="Text2" type="text" value="Some Text" />
<input id="Button1" type="button" value="Some Button" />
So as soon as you set focus on the textbox, the textbox turns grey indicating that it is read-only and the user is prevented to modify the text.