# Javascript validations for word count in fckeditor

**URL:** <https://www.ruby-forum.com/t/javascript-validations-for-word-count-in-fckeditor/187254>\
**Category:** Rails\
**Created:** [April 20, 2010, 4:54pm UTC](https://www.ruby-forum.com/t/javascript-validations-for-word-count-in-fckeditor/187254 "2010-04-20T16:54:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@sunny](https://www.ruby-forum.com/u/sunny)\
**Post date:** [April 20, 2010, 4:54pm UTC](https://www.ruby-forum.com/t/javascript-validations-for-word-count-in-fckeditor/187254/1 "2010-04-20T16:54:53Z")

</div>

I need to count the number of words in fckeditor using javascript

---

<div class="post-metadata">

**Author:** ![sunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@sunny](https://www.ruby-forum.com/u/sunny)\
**Post date:** [April 20, 2010, 10:07pm UTC](https://www.ruby-forum.com/t/javascript-validations-for-word-count-in-fckeditor/187254/2 "2010-04-20T22:07:54Z")

</div>

sunny wrote:

> I need to count the number of words in fckeditor using javascript

Did you make any effort to search this out for yourself. There are  
plenty of examples of this to be found using a simple Google search.

Google: javascript word count

And to get you started you could base a solution around:  
my\_text\_field.split(/\s/).length

---

<div class="post-metadata">

**Author:** ![sunny](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7c8e57/32.png) [@sunny](https://www.ruby-forum.com/u/sunny)\
**Post date:** [April 20, 2010, 10:20pm UTC](https://www.ruby-forum.com/t/javascript-validations-for-word-count-in-fckeditor/187254/3 "2010-04-20T22:20:51Z")

</div>

Robert W. wrote:

> And to get you started you could base a solution around:  
> my\_text\_field.split(/\s/).length

Correction: Make sure you get the string value for the text field for  
use with split():

jQuery example:  
$(’#my\_text\_field’).val().split(/\s/).length
