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.
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.
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.
This looks good, but how do I incorporate this with GF? Where do I place the code to make this work?
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.
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.
I would like character limit support as well!
Thanks for the solution Kevin, worked great. It would be nice to have this built into the plugin if possible though.
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.
+1 really excited about seeing this as an upcoming feature in 1.4... nice!
Yep, agreed. My client needs character limits on most of the fields, so I really look forward to integration with the new release! Thanks.
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!!!!
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.
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.
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...
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/
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...
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.
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?
I have updated your other post
http://forum.gravityhelp.com/topic/random-chanracters-in-hidden-field#post-5029
Hey, So I tried using the code for the character limit and it works in firefox, but not safari, or ie any suggestions?
NK
Glad I found this thread. Am also looking for the implementation of maxlength in textareas. Can't wait to see it in Gravity Forms.
Max Characters would be great for me too! 1.4 will be awesome!!!!