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;
}
Such an excellent and interesting information in your blog, it is awesome to read and do post like this with more informations. Salesforce Training USA
ReplyDeleteImplementing JavaScript validation for a gridview streamlines data input. How Tv Install By validating user inputs before submission, errors are caught in real time, improving data accuracy and user experience.
ReplyDelete