You could use onkeyup to test if the first part of the textarea content matches what it is supposed to be and change it back if it isn't. That would mean that if they type a one character change into the 'read only' portion it would be immediately changed back and if they pasted something in place of part or all of it the part of what is pasted over the 'read only' section would be immediately changed back. It wouldn't prevent them making a change to the 'read only' portion but it would prevent that change from still being there when they enter another character.
A simpler alternative is to display the fixed portion in a separate 'readonly' textarea immediately before the one they can edit and join the two fields together after the form has been submitted. For example the following displays two overlapping textareas so they look like one with the content of the first being readonly:
Code:
<style>
.var {margin-top : -15px;border-top:none;}
</style>
<form>
<fieldset><legend>Textarea with Fixed Text Portion</legend>
<textarea readonly="readonly" cols="50" rows="2">This part of the textarea content is fixed and cannot be changed</textarea><br/>
<textarea class="var" cols="50" rows="10">but the rest of the textarea content can be changed to whatever you want.</textarea>
</fieldset>
</form>
Bookmarks