Count Characters Inside Fields
Contents
Overview
This sample code counts the number of characters in a Text in Text area field.
Spaces in the text field are excluded from the count. The final count value is set into a Number field.
Sample Image
The number of characters are counted upon saving the record. The Number field is also un-editable when creating or editing the record.
Prepare the App
Create an App
including the following fields and settings.
| Field Type | Field Name | Field Code |
|---|---|---|
| Text or Text area | Body | body |
| Number | Number of Characters | count |
Sample Code
Prepare the following JavaScript code in a text editor and navigate to the Kintone App's settings.
Upload the file into the Upload JavaScript for PC option of the JavaScript and CSS Customization settings. For more information, refer to the following article on the Kintone Help site:
Customizing an app using JavaScript and CSS
.
|
|
After saving the settings and clicking on Update App, create a new record in the App.
Enter some characters into the Body field, and save the Record. The number of characters should be inserted into the Number of Characters field.