How can I change the character limit wording?
I am using WP in other language so "0 of 2000 max characters" doesn't look good. I'd rather prefer something like "0/200".
Thanks
How can I change the character limit wording?
I am using WP in other language so "0 of 2000 max characters" doesn't look good. I'd rather prefer something like "0/200".
Thanks
Gravity Forms uses this script to count characters in a textarea:
http://roy-jin.appspot.com/jsp/textareaCounter.jsp
Looking at those docs, it seems like you want to use displayFormat. Your display format would look something like this:
[js]
$jQuery(document).ready(function(){
var options = {
'displayFormat' : '#input / #max'
};
$('#yourtextareaID').textareaCount(options);
});
You will be adding JavaScript to the head of the page that contains the form with your textarea:
http://www.gravityhelp.com/documentation/page/Where_Do_I_Put_This_Code%3F
Thank you, Chris!
Ah, it alsmost worked.
It displays as:
3 of 2000 max characters
3 / #max
Now. So the previous text is still present and also maximum number of characters is not displayed properly.
Do you have a link to your page? It's possible that this script is being included before Gravity Forms includes their script, so theirs runs later?
I think #max not working is because of the same thing. The #max shorthand will only work when maxCharacterSize is defined (by default it's -1), and my guess is that the limit is coming from Gravity Forms later. Please post a URL to your page, or see if the order of the scripts might be fouling things.
I can't provide the link right now as I am doing it on local server.
I checked the order of scripts in head through firebug, and the script you provided is the last one, just before the closing </head>.
I tried putting it earlier, just after <?php wp_head(); ?>, but with the same result.
While reading the documentation today, I found a hook we should be using instead: gform_counter_script
http://www.gravityhelp.com/documentation/page/Gform_counter_script
Try this in your functions.php
[php]
// change the 6 here to your form ID
add_filter("gform_counter_script_6", "set_counter_script", 10, 4);
function set_counter_script($script, $form_id, $field_id, $max_length){
$script = "<script type='text/javascript'>//<![CDATA[\n jQuery(document).ready(function(){" .
"jQuery('#{$field_id}').textareaCount(" .
" {" .
" 'maxCharacterSize': {$max_length}," .
" 'originalStyle': 'ginput_counter'," .
" 'displayFormat' : '#input / #max'" .
" })});" .
"\n//]]></script>";
return $script;
}
?>
Sorry about that.
it works great, thanks!
Is there a simple way to make this global? So when I add new forms they look the same?
Yes, just remove the "_6" from the "gform_counter_script_6" - that will apply it to all forms, not just form 6. The 6 is your form ID. Most of the Gravity Forms hooks and filters work in the same manner (global or form-specific.)
Make the second line look like this:
add_filter("gform_counter_script", "set_counter_script", 10, 4);
That worked perfectly.
Another great solution from GF support!
Thank you.
Awesome, glad you got that working.