jquery find the next/nearest multiple number of another number
<p>I have a <code>&lt;table&gt;</code> with dynamically generated rows (<code>&lt;tr&gt;’s</code>).</p>

<p>In each row, I have a particular cell (<code>&lt;td&gt;</code>) in which I display a textbox. Within that textbox, I’ve added a custom <code>data-roundingrule</code> attribute which holds a particular value (in each row, the data-roundingrule attribute may (or may not) have a different value).</p>

<p>Here are two examples of what those textboxes might look like:</p>

<pre><code>&lt;input type=”text” id=”txt-1” name=”txt-1” data-roundingrule=”2”&gt;
&lt;input type=”text” id=”txt-2” name=”txt-2” data-roundingrule=”13”&gt;
</code></pre>

<p>My goal is to create a change event on every textbox that verifies if the entered value (by the user) is a multiple of the value stored in the <code>data-roundingrule</code> attribute.</p>

<p>If the entered value by the user is a multiple of the <code>data-roundingrule</code> attribute then great! Leave things as is…</p>

<p>If the entered value by the user is not a multiple of the <code>data-roundingrule</code> attribute then find/get/obtain the next nearest number that will be a multiple of the <code>data-roundingrule</code> attribute.</p>

<p>Here’s an example:</p>

<p>Considering the above two textboxes, in textbox 1, the user enters the value 1. The change event verifies if the value 1 is a multiple of the data-roundingrule set to 2. Since it’s not the case, then I need to change the value entered by the user and set it to 2.</p>

<p>Likewise for the second textbox…assuming the user has entered the value 4 in the textbox, 4 is not a multiple of 13, so I need to change the user’s input from a 4 to a 13.</p>

<p>If the user has entered the value 16 in the second textbox, 16 is not a multiple of 13 so I need to change the user’s input from a 16 to a 26 (which is the next multiple).</p>

<p>Hope this makes sense…</p>

<p>Sincerely and thanks in advance!</p>
