Skip to main content

Limit numer of character typed into a textbox or textarea

jQuery('#textArea').keypress(function() {
	var text = jQuery('#textArea').val();
	if(text.length > 400) {
		text = text.substring(0, 400);
		jQuery('#textArea').val(text);
	}
});

Ref: http://stuntsnippets.com/jquery-substring/