Users of my site have to input text by custom forms, with some custom fields. I need to limit the lenght of the text the user input in front end form and display (if possible) a counter with characters left. How can I do?
Thanks.
thank you for your quick answer. Where I should put the code suggested in the solution? I've tried in the form editor (expert mode) modifying the html and inserting the jquery in the JS editor, but it doesn't work. How can I do?
Can you send me a screenshot of your form in the expert mode as well as the code itself as well ?
If possible can you highlight the field that it should apply to ?
finally i've solved the problem searching for solution in other forum posts.
Here's the code i've put in the JS section:
jQuery(document).ready(function ($) {
$('textarea[name="wpcf-breve-nota-biografica"]').attr('maxlength',1500);
});
// Conta i caratteri inseriti
( function( $ ) {
$( document ).ready( function(){
// insert div to display char count
$('textarea[name="wpcf-breve-nota-biografica"]').after("Caratteri rimanenti: <span class='char-count'>1500</span>");
// listen for keyup and update the count
$('textarea[name="wpcf-breve-nota-biografica"]').keyup( function(){
var chars = 1500-$('textarea[name="wpcf-breve-nota-biografica"]').val().length;
$('.char-count').html( chars );
});
});
})( jQuery );
I've two other questions:
1) labels for radio custom field don't wrap. How can I do?
2) Given that Conditional display is not supported for User fields, how can display option in radio custom field based on value of previous custom radio field?