Client Script Question...

Client Script Question...

Hi I have written this bit client script but it doesnt seem to be playing ball, essentially I want a notification to ping, when a user goes to edit the field "Total_Refund" but if it exceeds "Total_Spend" it clears the value and notifies accordingly. Can anyone help? 

{
    // Get references to the necessary fields
    totalSpendField = input.Total_Spend;
    refundField = input.Total_Refund;

    // Attach an event listener to the refund field for dynamic validation
    refundField.on("change", validateRefund);
}

// Validation function
validateRefund()
{
    totalSpend = totalSpendField.get(); 
    refundValue = refundField.get(); 

    if (refundValue > totalSpend)
    {
        alert("Refund cannot be greater than the total spend (£" + totalSpend + ").");
    refundField.set(""); // Clear the invalid refund value
    }
}

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now