I'm modding some jquery code to limit the word count of a textfield but I can't figure out how to get the value. Here's the code:
<script>
var $limitWords = 20;
var $wordCount = $('#count').val();
$(document).ready(function(){
$("#edit-field-message-0-value").keyup(function() {
$('#count').html($('#edit-field-message-0-value').val().split(/\b[\s,\.-:;]*/).length);
if ($wordCount > $limitWords) {
$('#edit-field-message-0-value').addClass('error');
} else {
$('#edit-field-message-0-value').addClass('not-error');
}
});
});
</script>
Specifically, what should "$wordCount" be equal to to return the current value?
I think it should be easy, but I can't seem to figure it out.
Any ideas?
Thanks, Scott