How To Count Words in javascript?

74 views

There may be one more function that you have to use with length attribute to count words in textbox and textarea that is:

split function with argument as delimiter:
this has the property to split the objects value in array according to given arguments. In the example given below we use split(” “) ,this means split function breaks the string in array as it encounters ” ” or space or delimiter.
Demo:

  1. <textarea cols="50" rows="5" name="" id="" onkeyup="getElementById(’count_word’).value = this.value.split(’ ‘).length-1"></textarea>
  2. <input type="text" size="10" id="count_word">



« Count Character Written in textarea or textbox in javascript Use of window.open method in javascript »
Posted on Tuesday, April 28th, 2009 at 4:11 pm under Javascript | RSS 2.0 Feed

Post Comment

You must be logged in to post a comment.



ComputerEducationWorld.com All Rights Reserved © RSS | CBSE | Education Boards Of India | What is My IP?