Gautam Buddha Temple Varanasi,Varanasi - Buddhist Pilgrimage

Tuesday, March 30, 2010

Validate GridView textbox in clientside using javascript

 Find Gridview TextBox in client side using javascript  
 Here this article show show how we can find gridview textbox which is inside Template Field and validate the entry while
editing the record.  
 function ValidateGridEditMode()  
 {  
      var n = document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp').rows.length;  
      var i;  
      for(i=2; i <=n; i++)  
      {   
           if(i<10)  
           {  
                txtEmpName=document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp_ctl0'+i+'_txtEmpName');   
           }  
           else  
           {  
                txtEmpName=document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvEmp_ctl'+i+'_txtEmpName');   
           }  
           if(txtEmpName !=null)  
           {  
                if(txtEmpName.value == "")  
                {  
                     alert("Enter Emp Name...!");   
                     txtEmpName.focus();   
                     return false;  
                }   
           }   
      }  
      return true;  
 }  

1 comment:

  1. I have tried this way. it is not, working any thing to be added in .aspx or .aspx.cs along with this. Please clarify.
    P.Malathi
    bfgcpm@rediffmail.com

    ReplyDelete