1. Overview This article shows how to calculate leave or balance days inside a Joget form using JavaScript. The script reads date fields, calculates the number of selected days, validates against available balance, and updates the remaining balance field. 2. How It Works Make the calculated field read-only. Listen for changes on start_date, end_date, request_type, and total_days. Calculate days between the selected dates. Compare requested days against the available balance. Clear invalid input when the user exceeds the balance. 3. Where to Use in Joget Form Builder: custom HTML element or form-level JavaScript. Userview: forms where users submit leave or allocation requests. Workflow Builder: request forms before approval routing begins. 4. Full Code <script type= "text/javascript" > $ ( document ). ready ( function (){ $ ( ' [name=requested_days] ' ). prop ( " readonly " , true ); //Calculate days taken $ ( ' [name$=end_date] ' ). change ( function () { var myDate1 = $ ( ' [name$=start_date] ' ).β¦