I am trying to validate row of textboxs. If any of the textbox values in that row are entered, then the user must enter all the textbox values in that row. It should also focus on the empty row. Else he should be able to submit the form. I tried the below code but it is looks like that there is a logic issue. Please help me


PHP Code:
<script>
function 
checkVal()
{
    var 
counter 0;
    var 
a  =  document.getElementById('name'+counter).value;
    
alert(a);
    for(var 
i=0i<10i+5)
        {
 if(
a.length>1)
     {
     var 
document.getElementById('name'+counter).value;
     for(var 
k=0k<5k++)
         {
         if(
k[i].length<0)
             {
             
alert("Enter Values for all rows.");
             
k[i].focus();
             return 
false;
             }
         return 
true;
         }
     }
        }
    }
</script>
<form name="na"  onsubmit="return checkVal()">
<table>
      <tr>
  <td><input type="text" name="s1" id="s1" value="1" size="2" readonly="readonly"/></td>

<td><input type="text" name="name0" id="name0" size="20"> </td>
 <td><input type="text" name="name1" id="name1" size="20"> </td>
 <td><input type="text" name="name2" id="name2" size="20"> </td>
 <td><input type="text" name="name3" id="name3" size="15">  
 <td><input type="text" name="name4" id="name4" size="15">  
 </tr>
  <tr>
 <td><input type="text" name="s1" id="s2" size="2" value="2" readonly="readonly"/></td>
 <td><input type="text" name="name0" id="name5" size="20"> </td>
 <td><input type="text" name="name1" id="name6" size="20"> </td>
 <td><input type="text" name="name2" id="name7" size="20"> </td>
 <td><input type="text" name="name3" id="name8" size="15">  
 <td><input type="text" name="name4" id="name9" size="15"> 
 </tr>
  <tr>
  <td><input type="text" name="s1" id="s3" size="2" value="3" readonly="readonly"/></td>
 <td><input type="text" name="name0" id="name10" size="20"> </td> 
 <td><input type="text" name="name1" id="name11" size="20"> </td>
 <td><input type="text" name="name2" id="name12" size="20"> </td>
 <td><input type="text" name="name3" id="name13" size="15">  
 <td><input type="text" name="name4" id="name14" size="15"> 
 </tr>
</table>

<input type="submit" value="Submit">
</form>
</body>