Results 1 to 3 of 3

Thread: words count validation

  1. #1
    Join Date
    Jun 2008
    Posts
    114
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default words count validation

    hi

    i need to count the number of words in the text area. if exceeds then give alert.

    i m using this validation but this counts the characters not words

    Code:
    <script language="javascript">
    function alerty()
    {
    if(document.myform.w.value.length>5)
    	{
    		alert("words limit exceeded");
    		return false;
    	}
    }	
    </script>
    Code:
    <textarea rows="15" name="w" cols="45"></textarea>
    vineet

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    28,922
    Thanks
    43
    Thanked 3,187 Times in 3,151 Posts
    Blog Entries
    12

    Default

    Code:
    <script type="text/javascript">
    function alerty()
    {
    if(document.myform.w.value.split(' ').length > 5)
    	{
    		alert("words limit exceeded");
    		return false;
    	}
    }
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jun 2008
    Posts
    114
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default words count

    Quote Originally Posted by jscheuer1 View Post
    Code:
    <script type="text/javascript">
    function alerty()
    {
    if(document.myform.w.value.split(' ').length > 5)
    	{
    		alert("words limit exceeded");
    		return false;
    	}
    }
    </script>

    hi john

    thanks. it works perfect

    vineet

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •