{
// 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
}
}