PoliDev
PoliDev

Reputation: 1458

how to disable exists content in a textbox in jquery html5

I created one multi line text box.In that text box every time some remarks should be added with the different users. But existing content would not change or delete. The new text should add with that text box.

I tried the many ways to do this. But i can't find any one idea. People please help me to fix this issue.

<%: Html.TextArea("Remark", Model.Remarks, new { @maxlength = "400" })%>

Upvotes: 1

Views: 71

Answers (1)

Rachel Gallen
Rachel Gallen

Reputation: 28563

This is just an example. Its better to have an input below the text area to get the text from to append and then clear it once appended, but you get the gist. It requires jquery.

(function($){
    $.fn.extend({
        valAppend: function(text){
            return this.each(function(i,e){
                var $i =$('#remark')
                var $e = $('#comment');
                $i.val($i.val()  +'\n'  + $e.val());
            });
        }
    });
})(jQuery);


$('#append').click(function(){
    $('textarea').valAppend();
    $('#comment').val('');
    $('textarea').attr('readonly','readonly');
});
textarea, input{display:block;}
#remark{height:100px; width:200px;border: 1px solid black}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<textarea id="remark"></textarea>
<input type="text" id="comment" placeholder ="enter commment"></input>
<input type="button" id="append" value="append" />

Upvotes: 2

Related Questions