Gautam Buddha Temple Varanasi,Varanasi - Buddhist Pilgrimage

Friday, September 10, 2010

Javascript validation for Gridview footer textbox

 Javascript validation for Gridview footer textbox  
 Here gridview have footer row that cantain dropdownlist and two textbox.This javascript validate these fields while inserting record in database.  
 function ValidateGrid()  
 {   
      ddlNewCountry = document.getElementById('<%=((DropDownList)gv.FooterRow.FindControl("ddlNewCountry")).ClientID%>');  
      txtNewEmpName = document.getElementById('<%=((TextBox)gv.FooterRow.FindControl("txtNewEmpName")).ClientID %>');  
      txtNewAge = document.getElementById('<%=((TextBox)gv.FooterRow.FindControl("txtNewAge")).ClientID %>');  
      if(ddlNewCountry.value == 0)  
      {  
           alert("Please Select Country...!");  
           ddlNewCountry.focus();  
           return false;  
      }  
      if(txtNewEmpName.value == 0)  
      {  
           alert("Please Enter Emp name...!");  
           txtNewEmpName.focus();  
           return false;  
      }  
      if(txtNewAge.value == 0)  
      {  
           alert("Please Enter age...!");  
           txtNewAge.focus();  
           return false;  
      }   
      return true;   
 }  

No comments:

Post a Comment