Limit Words in a textarea using JQuery

HTML

<textarea id="detailed"></textarea>Detailed decription<br /><span id="detailedleft"></span>

JQuery

$('textarea#detailed').keyup(function() {
var len = (this.value.split(' ').length) -1;
if (len >= 250) {
this.value = this.value.substring(0, 250);
}
$('#detailedleft').text(250 – len + ' words left');
});

About Keiron

Web Developer based in the UK. Click here if you want to work with me