How to calculate sum on change?
<p>How to go about calculating the sum of two fields on change?</p>

<p>My HTML</p>

<pre><code>    &lt;div class="field"&gt;
    &lt;label for="field1"&gt;F1:&lt;/label&gt;
    &lt;input type="number" name="field1" min="0" placeholder="0" Title="Only positive numbers" required&gt;&lt;/div&gt;
    &lt;div class="field"&gt;
 &lt;label for="field2"&gt;Field2:&lt;/label&gt;
&lt;input type="number" name="field2" disabled&gt;
&lt;/div&gt;
</code></pre>

<p>And i got this but unsure on how this works/how to get it to work.. </p>

<pre><code> &lt;script&gt; $(".input").on("change", function(){
        var ret = Number($(".field1").val()) + Number($(".field2").val());
        $("#field3").val(ret);
</code></pre>

<p>Is there an easier way to do this? </p>