How to check number being entered in textbox dynamically?
<p>i have 5 textbox like</p>

<pre><code>&lt;input type ="text" size="3" name="r"&gt;&lt;br&gt;
&lt;input type ="text" size="3" id="1" onchange="vali(this.id)" name="I"&gt;&lt;br&gt;
&lt;input type ="text" size="3" name="a"&gt;&lt;br&gt;
&lt;input type ="text" size="3" name="s"&gt;&lt;br&gt;
&lt;input type ="text" size="3"  name="e"&gt;
function vali(d){
if(document.getElementById(d).value &lt;0 || document.getElementById(d).value &gt;=30)}
</code></pre>

<p>I want user should enter only max 2 digits on each field between 0 &amp; 30. I'm not able to restrict user to enter only 2 digits in field, for example when user enters 151, 15 should come on 1st field and then focus will go on 2nd field automatically and remaining digits will be entered in 2nd field and will be there till the user enters another digit. After entering focus will come on field 3 like this. Also I need to check to each field contain a number between 0 and 30 which I'm checking in above code.
Also when user submit the form all field should be checked for value between (0 to 30) If there is any field present alert bos should pop up  else go to next page.i m not able to do this part .this is my form part above the 5 input field</p>

<pre><code>&lt;form name="detail" action ="selectjzone.jsp" onsubmit="return validate(this)"&gt;
</code></pre>

<p>and edited  part is</p>

<pre><code>if (num &lt; 0) {
alert("The value enteres for " +" " + document.getElementById(obj.id).name + " " +  "is  outside the range0 to 30" );
return false;
} else if (num &gt; 30) {
alert("The value enteres for " +" " + document.getElementById(obj.id).name + " "+      "is  outside the range0 to 30" );
return false;
}
    return true;
</code></pre>

<p>}</p>
