Character count

This sample code counts the number of characters in a text field. Spaces in the text field are excluded from the count. The final count value is set into a number field.

Sample Image


Sample Code

// Count number of characters in the text field and set it in the number field
(function() {
    "use strict";
    var BODY = "body"; //field code of text or text area field
    var COUNT = "count"; //field code of number field['app.record.create.submit','app.record.edit.submit','app.record.index.edit.submit'], function (event) {

            // Obtain characters in the text field
            var rec = event.record;
            var st = rec[BODY]['value'];
            //Remove spaces
            var st2 = st.replace(/\s+/g, "");
            //Enter character count into number field
            rec[COUNT]['value'] = st2.length;
            return event;


Make sure to match the Field code of your fields, with the Field code written in the code.


Refer to the Tutorial page, on how to add scripts to your app.

Was this article helpful?
0 out of 0 found this helpful
Please sign in to leave a comment.