function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Derek Patrick DayaDerek Patrick Daya 

Count number of Characters on a textarea field on Visualforce Page when rendered stops working

Hi Everyone,

I am currently facing an issue on a VF page I've created which uses a Javascript to count number of characters on a inputtextarea as users type in. This works very well but with the new requirements to improve the VF page wherein there has to be different character limit per country I was force to use render function. Before the section where the textarea field is located the counter works well but right after it gets rerendered the javascript stopped working.

I've inspected the page before the render and after the render, and this part of the code went missing after rerendering.
<div class="jqEasyCounterMsg" style="font-size: 12px; font-family: Arial; color: rgb(0, 0, 0); text-align: right; width: 600px; opacity: 0;">Characters: 0/210</div>

Thank you in advance for any inputs!

Best Answer chosen by Derek Patrick Daya
SKSANJAYSKSANJAY
Hi Derek,

The concept of rerendering is to re construct the whole section based on new data supplied to page. In this case the javascript written outside that rendered section scope will not work as it loses control on that section after rerendering. So just keep your javascript code inside that rendered block then it will work as expected after rerendering as well.

All Answers

SKSANJAYSKSANJAY
Hi Derek,

The concept of rerendering is to re construct the whole section based on new data supplied to page. In this case the javascript written outside that rendered section scope will not work as it loses control on that section after rerendering. So just keep your javascript code inside that rendered block then it will work as expected after rerendering as well.
This was selected as the best answer
Derek Patrick DayaDerek Patrick Daya

Wow! Thank you for your input SKSANJAY it worked well after I've applied the moved the script inside the pageBlock.

Thank you so much!

SKSANJAYSKSANJAY
Most welcome Derek...Feel free to post wherever you need help....