I have one text area in which i want to allow only 30 words and remove remaining extra words.
$("#short_desc").keydown(function(e){
var d = $(this).val().split(/\b[\s,\.-:;]*/).length;
if(d > 30){
alert("Only 30 words allowed");
e.preventDefault();
// here i want to add logic how to remove words.
return false;
}
});
I have tried with character count but cant short out this logic can some one provide some hint. I have one logic that count spaces and then count character count till 30 spaces and get sub string before that character count.
Aucun commentaire:
Enregistrer un commentaire