limit textbox characters using jquery

Jquery is best for client side operations. so this is simple snippet provided by MVC Snippets to you which restrict text boxes on specific characters

Create a new project in visual studio and make a simple ActionController and its corresponding view

View Code

<script src=""></script>
<script type="text/javascript">
$(function() {
var limit = 50;
$('textarea[id$=numbers]').keyup(function() {
var lenn = $(this).val().length;
if (lenn > limit) {
this.value = this.value.substring(0, limit);
$('#leftchar').text(limit - len + " characters left");

<h2>50 characters allow</h2>
<input type="text" id="numbers"> 
<span id="leftchar"></span>

For more jquery snippets please visit Jquery section