Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

How to count the characters in textarea when typing? How to achieve in SAP CRM Web ui?

Hello Experts,

I have one requirement, Need to count the characters in the textarea field when typing.

strlen( ), this string operation only count the total characters. But My requirement need the count the characters when typing.

Kindly Help me with solution and Thanks in advance.

Former Member
Former Member replied

Hi Shaik,

First of all Sorry for the late reply...

In that case you have to get the standard text field ID (LINES) based on that count the characters which you have passed in the notes field and based on length have to rise the alert..

this is the snippet code for that..


   data: lv_fieldname type string,

           lv_contextnode type string,

           lv_id type string.

           lv_fieldname = 'links'.   " fieldname ( only small letters )

           lv_contextnode = 'contextnode'" context node name in which the field is present.

   CONCATENATE controller->component_id '_' lv_contextnode '_' lv_fieldname INTO lv_id.

<script type="text/javascript">

var NoteID = document.getElementById("<%= lv_id %>");

NoteID.addEventListener("keyup", myFunction);

function myFunction() {

var count ;

count = document.getElementById("<%= lv_id %>").value;

if(count.length == 10) {

alert("Please enter less than 10 Chars ");


// this is for display the count in input field...

document.getElementById("NoteId").value = count.length;



<thtmlb:textArea id   = "NoteId"

                  rows = "1"

                  text = "" />



1 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question