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

**URL:** <https://forum.wixstudio.com/t/putting-conditions-on-user-input-number-fields-so-they-have-to-equal-a-certain-number-before-submission/17087>\
**Category:** Ask the community\
**Tags:** question, code\
**Created:** [July 20, 2019, 3:30pm UTC](https://forum.wixstudio.com/t/putting-conditions-on-user-input-number-fields-so-they-have-to-equal-a-certain-number-before-submission/17087 "2019-07-20T15:30:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![megansauer](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/megansauer/32/13286_2.png) [@megansauer](https://forum.wixstudio.com/u/megansauer)\
**Post date:** [July 20, 2019, 3:30pm UTC](https://forum.wixstudio.com/t/putting-conditions-on-user-input-number-fields-so-they-have-to-equal-a-certain-number-before-submission/17087/1 "2019-07-20T15:30:17Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Shan](https://sea1.discourse-cdn.com/wix/user_avatar/forum.wixstudio.com/shan/32/106059_2.png) [@Shan](https://forum.wixstudio.com/u/Shan)\
**Post date:** [July 20, 2019, 5:32pm UTC](https://forum.wixstudio.com/t/putting-conditions-on-user-input-number-fields-so-they-have-to-equal-a-certain-number-before-submission/17087/2 "2019-07-20T17:32:42Z")

</div>

Hi

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

```javascript
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.
