Reputation: 487
I need to make some characters is not editable within the text area... I.e.
I have a text area name TxtMsg
and Id TxtMsg
and the Values is
Dear User, Thank you for your contact................... We will contact you soon ...Thanks again
Here user can type anything with in the ...................
IS it's possible?
Does anyone know this? Please Reply
Upvotes: 0
Views: 1698
Reputation: 17920
Using HTML5 contenteditable="true"
attribute, you can try something like this,
Demo: http://jsfiddle.net/muthkum/ZSNpQ/
Upvotes: 0
Reputation: 6858
jquery-keyfilter , This plugin filters keyboard input by specified regular expression.
e.g.
$("#input").keyfilter(/[^#\*@0-9]/);
OR
$("#input").bind("keypress", function(evt)
{
var charCode = (evt.which) ? evt.which : window.event.keyCode;
if (charCode <= 13) {
return true;
}
else {
var keyChar = String.fromCharCode(charCode);
var re = /[a-zA-Z]/
return re.test(keyChar);
}
}
Upvotes: 0
Reputation: 155558
Not with pure HTML, no (unless you follow @alexandernst's suggestion of making only the editable part an <input type="text" />
element).
With Javascript, you could hook the caret (see Caret position in textarea, in characters from the start ) and undo any changes to the text that aren't made within the range of the "." characters, but this would be overly complicated and wouldn't work on browsers that have scripting disabled.
Upvotes: 0
Reputation: 15099
You need to make only the ..............
a text area. The rest of the text should be HTML.
Upvotes: 5