title: How to validate textbox in gridview when checkbox is checked in same row of gridview using javascript asp.net
body: <p>i have gridview in my aspx page as</p>
  
  <pre><code> &lt;asp:GridView ID="Grid_FeeCategory" Width="100%" CssClass="table table-striped responsive-utilities jambo_table" runat="server" AutoGenerateColumns="False"&gt;
      &lt;HeaderStyle CssClass="headings" /&gt; 
      &lt;Columns&gt;
      &lt;asp:TemplateField&gt;
      &lt;HeaderTemplate&gt;
      &lt;asp:CheckBox ID="checkAll" runat="server" onclick = "checkAll(this);" /&gt;
      &lt;/HeaderTemplate&gt;
      &lt;ItemTemplate&gt;
      &lt;asp:CheckBox ID="chkRow" runat="server" onclick = "Check_Click(this)"/&gt;
      &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
      &lt;asp:BoundField DataField="CatName" HeaderText="Category" /&gt;
      &lt;asp:TemplateField HeaderText="Category Fee" HeaderStyle-Width="125px"&gt;
      &lt;ItemTemplate&gt;
      &lt;asp:TextBox ID="txtCatFee" runat="server" placeholder="Int or Decimal" style="width:100%" /&gt;
     &lt;/ItemTemplate&gt;
      &lt;/asp:TemplateField&gt;
      &lt;asp:BoundField DataField="FeeCatID" HeaderText="Category ID" HeaderStyle-CssClass="hidden-field" ItemStyle-CssClass="hidden-field"/&gt;
      &lt;/Columns&gt; 
  
      &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>and my <code>custom validator</code> looks like</p>
  
  <pre><code>&lt;asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Please enter value"
      ClientValidationFunction="Validate" ForeColor="Red"&gt;&lt;/asp:CustomValidator&gt; 
  </code></pre>
  
  <p>i need to validate <code>textbox</code> in <code>gridview</code> when <code>checkbox</code> in the <code>gridview</code> is checked and user leave <code>textbox</code> empty</p>
  
  <p>e-g if user check the checkbox from row 1 of gridview and also leave textbox empty in row 1 and so on.. then custom validator inform to enter value, </p>
  
  <p>for this i got javascript yesterday from google and manipulate it but it does nothing and here is <code>javascript</code> </p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
           function Validate(sender, args) {
               var gridView = document.getElementById("&lt;%=Grid_FeeCategory.ClientID %&gt;");
  
               var fields= gridView.getElementsByTagName("input");
  
               for (var i = 0; i &lt; fields.length; i++)
               {
  
                   if (fields[i].type == "fields" &amp;&amp; fields[i].checked)
                   {
  
                       if (fields[i].type == "text" &amp;&amp; fields[i].value.length &lt; 1)
                       {
  
                           args.IsValid = false;
                               return;
  
                         }
  
                   }
               }
               args.IsValid = true;
           }
           &lt;/script&gt;
  </code></pre>
  
  <p>i check it by using alerts inside script and it cannot enter into this section of <code>javascript</code></p>
  
  <pre><code>if (fields[i].type == "text" &amp;&amp; fields[i].value.length &lt; 1)
                       {
  
                           args.IsValid = false;
                           return;
  
                         }
  </code></pre>
  
  <p>It is requirement to do this at client side using <code>javascript</code> so i need your help to get out of it</p>