Putting conditions on user input number fields so they have to equal a certain number before submission

I have 3 user input fields in a form that are set to “number” which are used to indicate how much % they want to pay each year for 3 years. (the input fields are year 1, year 2, year 3). I want to make it so that the numbers in these fields need to add up to 100 otherwise it will not allow them to submit the form. Can someone point me in the right direction?

Hi

If you want to validate whether 3 different input fields add up to 100 or not, use the code below.

export function button1_click(event) {
 let total = Number($w("#input1").value) + Number($w("#input2").value) + Number($w("#input3").value);
 let roundOff = Math.round(total);
 if(roundOff === 100) {
        console.log('Condition Met');
    } else {
        console.log('Did not meet condition');
    }
}

You might want to use Math.round() to round off the value to the nearest integer otherwise it will be difficult to meet the exact value of 100.