> Forums > Active Social > Themes and Templates > jQuery MaxLength for TextArea
Last Post 04 Nov 2011 09:50 AM by Steven. 8 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
Jeff Blanks
Customers
Jeff Blanks
Post Count:387

--
28 Mar 2010 06:10 PM
    I was doing some digging and wanted to put a limit on the number of characters that can be entered into all the different text boxes in the journal. Especially true for the Status Updates. Most of which can be found in the JournalTools.ascx file.

    I came across a simple way to achieve this by using jquery and adding the maxlength attribute to the textarea box. Please note, if a user copies and pastes their info into a textarea, this script won't work and gets bipassed, but does work on key strokes.

    I also found that it will also work off the maxlength attribute found in input fields, so it can be used globally on your site if needed. See attached text document for the information.









    maxlength.txt

    Cheers! Jeff
    @northeastok | @jeffblanks | My Blog
    Tags: jQuery
    Ben - DotNetNuke
    DotNetNuke Staff
    Ben - DotNetNuke
    Post Count:1645

    --
    31 Mar 2010 11:28 AM
    Very cool, thanks for sharing this.


    Steven
    Registered Users
    Steven
    Post Count:32

    --
    22 Oct 2011 10:30 AM
    Jeff...

    Do you have any examples of how this is used in journaltools.ascx?  Or can you share any files/code on how you implemented this in AS?

    It would be apprectiated!


    Jeff Blanks
    Customers
    Jeff Blanks
    Post Count:387

    --
    27 Oct 2011 06:11 PM
    Steven,

    Did you see my attachment in the first post? Might be a little easy to miss, but it should have all the necessary scripting and html for an example.

    This is a snippet from my journaltools.ascx template:
    <textarea id="txtWallPost" cols="50" maxlength="240" rows="2" onfocus="if (this.value=='[RESX:WriteSomething]') this.value='';">[RESX:WriteSomething]textarea>
     <span class="dnnRight charsRemaining">span>
    And then you would want to add the script at the bottom of journaltools.ascx.

    If you need more help, let me know.



    Cheers! Jeff
    @northeastok | @jeffblanks | My Blog
    Jeff Blanks
    Customers
    Jeff Blanks
    Post Count:387

    --
    27 Oct 2011 06:13 PM
    Forums are eating up my code a little bit. That codeblock is missing some brackets.


    Cheers! Jeff
    @northeastok | @jeffblanks | My Blog
    Steven
    Registered Users
    Steven
    Post Count:32

    --
    03 Nov 2011 05:59 AM
    Jeff...

    Thanks for your response.  I did get this working and its great, especially with twitter integration.  My question if what specific code did you use in the journaltools.aspx to get the "characters remaining" feedback below the text input box that is shown on your screenshot?  Thanks again for your help, this is a great tool.

    Steve


    Jeff Blanks
    Customers
    Jeff Blanks
    Post Count:387

    --
    03 Nov 2011 05:52 PM
    All you would need to do is make an element such as div, p, span and place it right after the textarea element and add "charsRemaining" as a class to that element.

    ex. < p class="charsRemaining">< /p > (less all the extra spaces)

    You can then style the "charsRemaining" class.


    Cheers! Jeff
    @northeastok | @jeffblanks | My Blog
    Steven
    Registered Users
    Steven
    Post Count:32

    --
    04 Nov 2011 09:28 AM
    For some reason I can't get it show up.  I must be doing something wrong in the styling.


    Steven
    Registered Users
    Steven
    Post Count:32

    --
    04 Nov 2011 09:50 AM
    Got it working Jeff. Thanks for your help! Works perfectly!


    You are not authorized to post a reply.
    > Forums > Active Social > Themes and Templates > jQuery MaxLength for TextArea
    test
    Copyright 2012 by DotNetNuke Corporation / Terms of Use / Privacy