Fixed text in text area
The fixed text will not be editable or deletable. Insert the value of element to itself on focus to place the cursor at the end of fixed text
by Sree K
HTML
<input id="field" type="text" value="CAN'T TOUCH THIS!" size="50" />
<div id="output">
</div>
JavaScript
var readOnlyLength = $('#field').val().length;
$('#output').text(readOnlyLength);
$('#field').on('keypress, keydown', function(event) {
var $field = $(this);
$('#output').text(event.which + '-' + this.selectionStart);
if ((event.which != 37 && (event.which != 39))
&& ((this.selectionStart < readOnlyLength)
|| ((this.selectionStart == readOnlyLength) && (event.which == 8)))) {
return false;
}
});