Wednesday, July 8, 2009

Validate radio button in datagrid, datalist, gridview on button

Here  'questionlist' is the id of Datalist or datagrid or Gridview or repeater

u call this function on button events

<button onclick="return isconfirm()" />

<script language=javascript>
function isconfirm()
{

var counter=0;

var obj=document.getElementById("<%=questionlist.ClientID%>").getElementsByTagName("input");
for(i=0;i<=obj.length-1;i++)
{
if(obj[i].type=="radio" && obj[i].checked==true)
{
counter++;
}
}
if(counter==0)
{ alert('Plz Select question Answer');
return false
}
return true;
}

</script>
AJAX, asp, Asp.net, asp.net and sql server security, Asp.net IntemIndex, C#, Css, DataBinder.Eval, DataKeyNames, Datalist, Datapager, DataSet, DataTable, DropDownList, FindControl, gridview, JavaScript, jquery, Listview, Paging, Regex, RegularExpression, Repeater, Server side validation, Sql Server, timer, timercallback, Validation, XML, xmlnode, XPath