Wednesday, 3 July 2013

Gridview validation using JavaScript


In this article I will explain how to validate GridViewtextbox in JavaScript

I  can give u idea how to find gridviewtextbox using javascript here.I have done validation for country which is inside in grid.
you can also find your both textboxes in this way and compare that.


<script language="javascript" type="text/javascript">
function CountryInsertValidate()
{
txtNewCountry = document.getElementById('<%=((TextBox)gvCountry.FooterRow.FindControl("txtNewCountry")).ClientID %>');
//or find this way
//txtCountry=document.getElementById('ctl00_ContentPlaceHolder1_tbcLocation_tpnlCountry_gvCountry_ctl0'+i+'_txtCountry'); 
find here another textbox and compare
//if(txtNewCountry.value == "")
// {
//alert("Enter Country Name...!"); 
// txtNewCountry.focus(); 
// return false;
//} 
return true; 
}
</script>

No comments:

Post a Comment