Home › Forums › Quform WordPress › Character counter on multiple text area fields
- This topic has 2 replies, 2 voices, and was last updated 2 years, 6 months ago by MOVOX.
- AuthorPosts
- May 27, 2022 at 4:16 am #34295MOVOXParticipant
I have a multi-page form which has Text Area fields on certain pages. I would like to add a character counter (all with the same character limits) to each of these fields.
I have added the following code to the Custom CSS & JS settings and the character counter only appears below the field with the ID quform-field-2_857. The other 3 fields do not show the character counter.
The code below is also causing conditional logic to break. When I only list one form ID the counter works fine for the selected field and conditional logic also also working fine. I assume that I am entering the “Get text area field” string incorrectly?
Can you please help with this?
jQuery(function ($) {
var $counter = $(‘<div class=”character-counter”>’),
limit = 200;// Get the textarea field
$(‘.quform-field-2_425’);
$(‘.quform-field-2_534’);
$(‘.quform-field-2_683’);
$(‘.quform-field-2_857’);// Add the counter after it
.after($counter)// Bind the counter function on keyup and blur events
.bind(‘keyup blur’, function () {
var length = $(this).val().length;if (length > limit) {
// The value exceeds the limit, contain it
$(this).val($(this).val().substring(0, limit));
} else {
// Set the counter text
$counter.text(length + ‘/’ + limit + ‘ characters’);
}
})// Trigger the counter on first load
.blur();
});May 27, 2022 at 10:17 am #34303AllySupport StaffYou don't have permission to view this content. Please log in or register and then verify your purchases to gain access.
May 28, 2022 at 5:48 am #34306MOVOXParticipantThanks Ally, your new code works perfectly when displaying the character counter on multiple text area fields.
- AuthorPosts
- You must be logged in to reply to this topic.