Control a dynamically created <input />s (like name[]) doesn't sum more than 99, jQuery
<p>I've got a backend page where the client can add dynamically various <code>&lt;input /&gt;</code>s for declaring the percentage of participation of other people. Like: Company A colaborates with Company B and C that B has 10% and the C the 30%. Company A will have 60%.</p>

<p>The exactly <code>&lt;input /&gt;</code> is this:</p>

<pre><code>&lt;input type="text" name="percentage[]" value="0" /&gt; %
</code></pre>

<p>There is another one for the name of the company, but this doesn't needs any kind of control.</p>

<p>Now, when the user is filling the data and adds percentage, I've to calculate that the sum of all percentage[] it's less or equal to 99. I've to show on a <code>&lt;div /&gt;</code> the participation of company A depending of the percentage[] introduced and if the sum of percentage[] is =99 I can't let the user introduce bigger numbers on percentage[] inputs.</p>

<p>Example #1:</p>

<ul>
<li>Company B: 10%</li>
<li>Company C: 30%</li>
<li>Company D: 10%</li>
</ul>

<p>Total participation of Company A is 50%.</p>

<p>Example #2:</p>

<ul>
<li>Company B: 50%</li>
<li>Company C: 49% &lt;- the user can't put a number bigger than 49% because Company A will at least have a 1% of the participation.</li>
<li>Company D: 0% &lt;- can't have more percentatge </li>
</ul>

<p>Total participation of Company A is 1%.</p>

<p>First of all I know that I've to use .live() to handle this because is added in the DOM after the document.ready(). When typing, I assume that I've to check the sum every number and finally write to the div the percentage for company A depending on the array of percentage[].</p>

<p>Can someone help me with this?</p>

<p>Thank you in advance!</p>
