In this article I will tell you how you can display no of characters entered in textarea using jquery in you mvc2/mvc3/mvc4/mvc5 .
Some of my previous mvc articles are as follows: How to Create and Read Cookies In ASP.NET Using C#, Multiple File Upload With Asp.Net MVC C# and HTML5 | How to upload files to ASP.NET MVC application, How to get a User's Client IP address in ASP.NET using C#.Net, Drag Drop Cells in GridView Control Using Asp.net C# and jQuery, Multiple File Upload With Asp.Net MVC C# and HTML5 | How to upload files to ASP.NET MVC application, Display Alert Message on Page Load in MVC Application Using Javasscript.
@{
ViewBag.Title = "Display
No of Characters Entered In TextArea Using jQuery In MVC";
}
@using
(Html.BeginForm("Index", "Home", FormMethod.Post))
{
<h3>Display No
of Characters Entered In TextArea Using jQuery</h3>
<script src="http://code.jquery.com/jquery-1.8.3.js"></script>
<script language="javascript">
function
ValidateCharactercount(cont) {
var
id = "#" + cont.id;
$("#divmessage").html("Character Count :" +
$(id).val().length);
}
</script>
@Html.TextArea("TextArea",
"", new
{ @id = "txtdata", @onkeyup = "javascript:ValidateCharactercount(this);"
})
<div id="divmessage" style="color: Red;">
</div>
}
|
0 comments:
Please let me know your view