PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Limit characters in paragraph text field

  1. Is there a way to set a character limit on the paragraph text field? I can not see how and would like to do it. I have a field where I need to set a maximum of 1,400.

    Posted 14 years ago on Monday November 23, 2009 | Permalink
  2. There's no setting in GF right now to limit the amount of characters in the textearea/paragraph field. We may add that functionality in the future, but I'm not sure when right now. As an alternative, there are a few simple jQuery solutions out there that would do what you're looking for. I found this one in a quick search.

    http://www.unwrongest.com/projects/limit/

    I found several others so there are plenty of choices out there.

    Posted 14 years ago on Monday November 23, 2009 | Permalink
  3. This looks good, but how do I incorporate this with GF? Where do I place the code to make this work?

    Posted 14 years ago on Monday November 23, 2009 | Permalink
  4. I'm not 100% sure about that particular script having not tested it. You would just need to follow the implementation steps on their site.

    If you want something quick and easy, you can try this. I've used it before and it works well. It doesn't write out the number of characters left, but it does limit the characters in the textarea.

    copy this, save it as limit-textarea.js and upload it to your theme where other scripts are located (usually a js or javascript folder in the main theme directory).

    /***********************************************
    * Textarea Maxlength script- © Dynamic Drive (www.dynamicdrive.com)
    * This notice must stay intact for legal use.
    * Visit http://www.dynamicdrive.com/ for full source code
    ***********************************************/
    
    function ismaxlength(obj){
    var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
    if (obj.getAttribute && obj.value.length>mlength)
    obj.value=obj.value.substring(0,mlength)
    }

    or you can right click and save the file if you prefer.

    once you've uploaded the file to your theme, you'll want to open the header.php file, and include this script right before the </head> tag.

    <script src="<?php bloginfo('template_directory'); ?>/js/limit-textarea.js"></script>
    <script type="text/javascript">
    jQuery(document).ready(function() {
     		jQuery("#input_X_XX").attr("maxlength", "50");
     		jQuery("#input_X_XX").attr("onkeyup", "return ismaxlength(this)");
    	});
    </script>

    You'll need to replace the 2 instances of the input id in the example "input_X_XX' with the actual id of your textarea (view source to find that), set the maxlength (max number of characters) to your preference and you should be set.

    Note: I grabbed the script from this site and since you can't access the markup directly in the form, used a little jQuery to append the new attributes.

    Posted 14 years ago on Monday November 23, 2009 | Permalink
  5. Wow, I appreciate the info, but way out of my league... I guess I'll wait and see if you implement that at some point in a future release.

    Posted 14 years ago on Monday November 23, 2009 | Permalink
  6. I would like character limit support as well!

    Posted 14 years ago on Sunday January 3, 2010 | Permalink
  7. Thanks for the solution Kevin, worked great. It would be nice to have this built into the plugin if possible though.

    Posted 14 years ago on Monday January 11, 2010 | Permalink
  8. Glad it worked for you. The character limit is definitely going to make an upcoming release.. most likely version 1.4 which should be out pretty soon.

    Posted 14 years ago on Monday January 11, 2010 | Permalink
  9. +1 really excited about seeing this as an upcoming feature in 1.4... nice!

    Posted 14 years ago on Thursday January 21, 2010 | Permalink
  10. Yep, agreed. My client needs character limits on most of the fields, so I really look forward to integration with the new release! Thanks.

    Posted 14 years ago on Sunday January 31, 2010 | Permalink
  11. Any real time frame on 1.4? I really need this feature and the ablility to duplicate a form on another blog feature. I'm dying here!!!!

    Posted 14 years ago on Wednesday February 3, 2010 | Permalink
  12. bump! any word on v1.4 ??? I think this feature is needed as well as the ability to save the form for use on another website.

    Posted 14 years ago on Thursday April 22, 2010 | Permalink
  13. Yes there is an internal time frame on 1.4. But it's a big release. There will be a release (possibly 2) BEFORE 1.4, such as 1.3.12 which will be out soon.

    Posted 14 years ago on Friday April 23, 2010 | Permalink
  14. this didn't work for me. i uploaded the js, i found the id of the form element and put that in header. can you check out
    http://chinesefinearts.org/mj-registration-form/
    (pswrd is "!234")
    thoughts?

    i looked at the dynamicdrive method but not sure how i can add code to the form element?

    thanks!
    loving gravity forms. tempted to buy devel copy before wordcamp...

    Posted 14 years ago on Tuesday April 27, 2010 | Permalink
  15. My test on your form worked perfectly. It trimmed the field content at exactly 1400 characters which is what you specified in the script. I tested it in Firefox, Safari & Chrome on Mac.

    Note: If you're interested in upgrading to developer license, there are just a few days left to get in on the lifetime updates.

    http://www.gravityhelp.com/important-gravity-forms-announcement/

    Posted 14 years ago on Tuesday April 27, 2010 | Permalink
  16. thanks. it seems i was not testing it correctly. it is working.
    BTW, i submitted a request to upgrade to developer and have not heard back so please let me know if i should submit again?

    also, the other issue i have is in this post
    http://forum.gravityhelp.com/topic/random-chanracters-in-hidden-field#post-5029
    if perhaps you have some ideas on that issue?

    thanks again...

    Posted 13 years ago on Friday April 30, 2010 | Permalink
  17. Hello Ari, we will get back with you shortly on the Developer License upgrade. We are actually out of town right now so will be slow to respond to some of the upgrade requests... but rest assured we will get to them and they will still include lifetime support and upgrades despite the fact it is already May 1st.

    Posted 13 years ago on Saturday May 1, 2010 | Permalink
  18. thanks. i got my upgrade and paid for it. but i still need help on this issue
    http://forum.gravityhelp.com/topic/random-chanracters-in-hidden-field#post-5029

    is it better to start a new topic?

    Posted 13 years ago on Wednesday May 5, 2010 | Permalink
  19. I have updated your other post

    http://forum.gravityhelp.com/topic/random-chanracters-in-hidden-field#post-5029

    Posted 13 years ago on Wednesday May 5, 2010 | Permalink
  20. nkeebaugh
    Member

    Hey, So I tried using the code for the character limit and it works in firefox, but not safari, or ie any suggestions?

    NK

    Posted 13 years ago on Thursday May 6, 2010 | Permalink
  21. cnymike
    Member

    Glad I found this thread. Am also looking for the implementation of maxlength in textareas. Can't wait to see it in Gravity Forms.

    Posted 13 years ago on Tuesday May 18, 2010 | Permalink
  22. Max Characters would be great for me too! 1.4 will be awesome!!!!

    Posted 13 years ago on Tuesday May 25, 2010 | Permalink

This topic has been resolved and has been closed to new replies.