0

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

loler
  • 2,594
  • 1
  • 20
  • 30
user1519718
  • 457
  • 1
  • 5
  • 12

4 Answers4

5

You need to make only the .............. a text area. The rest of the text should be HTML.

alexandernst
  • 14,352
  • 22
  • 97
  • 197
0

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.

Community
  • 1
  • 1
Dai
  • 141,631
  • 28
  • 261
  • 374
0

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);
        } 
}
Sender
  • 6,660
  • 12
  • 47
  • 66
0

Using HTML5 contenteditable="true" attribute, you can try something like this,

Demo: http://jsfiddle.net/muthkum/ZSNpQ/

Muthu Kumaran
  • 17,682
  • 5
  • 47
  • 70