Add Leading Zeros to Numbers
Contents
Overview
This article introduces how to lead a number with 0s in a field of a Kintone App.
Sample Image
An event is triggered when the focus leaves the Number field while creating or editing a record. 0s are added to the beginning of the number until it reaches a fixed digit length. The result is inserted into the Result field.
Prepare the App
Create an App with the following fields and settings.
Field Type | Field Name | Field Code |
---|---|---|
Number | Number | number |
Text | Result | result |
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 .
|
|
After saving the settings and clicking on Update App, create a new record. Fill in the Number field with numbers, and take the focus off the field. A version of the number leaded with 0s should be inserted into the Result field.