In OAF page, if user want to know how many characters entered in message text input field. Below is the code we need to use in process request.
String customJSFunction1 = “function cntRemaingChars1() {\n” +
” var len = document.getElementById(\”item4\”).value.length;\n” +
” document.getElementById(\”item5\”).innerHTML = len+\” characters Entered\”;\n” +
“}”;
pageContext.putJavaScriptFunction(“cntRemaingChars1”, customJSFunction1); // Embed JavaScript function in the page
// Find the element on which you want to set the events for JavaScript function call.
OAMessageTextInputBean log1 = (OAMessageTextInputBean) webBean.findIndexedChildRecursive(“item4”);
log1.setAttributeValue(UIConstants.ON_KEY_DOWN_ATTR, “cntRemaingChars1();”);
log1.setAttributeValue(UIConstants.ON_KEY_UP_ATTR, “cntRemaingChars1();”);
log1.setAttributeValue(UIConstants.ON_MOUSE_OUT_ATTR, “cntRemaingChars1();”);