Limit Character Count For apex inputTextarea in Visualforce using AngularJS

Limit Character Count For <apex:inputTextarea> in Visualforce using AngulrJS

Below is the user interface that will be achieved

Character Count 1

In the screen-shot below I entered seven characters in the text area and the count indicates that there are 3 characters remaining.

Character Count 2


This topic – Limit Character Count For <apex: inputTextarea> in Visualforce, uses  AngularJS that is one of the  Javascript frameworks that one can use with Visualforce. AngularJS is a JavaScript framework. It can be added to an HTML page with a <script> tag. AngularJS extends HTML attributes with Directives and binds data to HTML with Expressions written inside double braces: {{expression}}.  AngularJS directives extend HTML attributes with the prefix  ng-. The ng-app directive initializes an AngularJS application while the ng-model directive binds the value of HTML controls (input, select, textarea) to application data.                                  To learn more on AngularJS, go to

In this post, two codes will be attached:

  • The first code uses Html input textarea with the  AngularJS  Directives added to the form and the input tags.
  • The second code will use <apex:inputTextarea> component where I will add AngularJS  Directives using the  HTML pass-through attributes.

The Visualforce code with HTML form and input tags:

Note: within the <head> tag, there are two <script> tags. The first one is a Javascript file that you must add to the web page with a script tag for AngularJS to render on the page. The second tag is the code. I also added a <style> tag to center the page title and style the textarea’s label. If you omit the style, the label will be below the textarea instead of where it is in the screen-shot.

Adjust the maxlength value for the need of your business requirements.

Visualforce code using <apex:inputTextarea>:

This code is added to demonstrate how you can easily use the Html pass-attributes in Visualforce. It also shows how to use Visualforce with AngularJS. Check the binding of the controls with the application data using the ng-model in both codes and the use of AngularJS Expression in <apex:outputText>.

If you have any question on the topic, contact me through my email.

This Post Has One Comment

  1. Hi
    senior salesforce RQ developer 501 certs or salesforce architect its a REMOTE JOB US citizen 1 yr
    Cal 281 306 6691

Leave a Reply

Close Menu