Interface code:
Copy Code code as follows:
<form id= "Form1" runat= "Server" >
<div align= "center" >
<fieldset style= "width:350px; height:200px; " >
<table border= "0" cellpadding= "3" cellspacing= "3" >
<tr>
<td>
Please choose the type of car:
</td>
</tr>
<tr>
<td>
<asp:radiobuttonlist id= "Rbcar" runat= "Server" >
<asp:listitem value= "1" text= "Mercedes Benz Car" ></asp:ListItem>
<asp:listitem value= "2" text= "BMW Car" ></asp:ListItem>
<asp:listitem value= "3" text= "Audi car" ></asp:ListItem>
<asp:listitem value= "4" text= "Hyundai Motor" ></asp:ListItem>
<asp:listitem value= "5" text= "Toyota Motor" ></asp:ListItem>
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td>
<asp:button id= "btnsubmit" runat= "Server" text= "Submit"/>
</td>
</tr>
</table>
</fieldset>
<asp:customvalidator id= "Ctvcar" runat= "Server" display= "Dynamic" errormessage= "select at least one car!" "
Forecolor= "Red" clientvalidationfunction= "Rbcar_validation" ></asp:CustomValidator>
</div>
</form>
Scripting code:
Copy Code code as follows:
<title>Recipe16</title>
<script type= "Text/javascript" src= "Scripts/jquery-1.4.1-vsdoc.js" ></script>
<script type= "Text/javascript" >
function rbcar_validation (sender, args) {
Args. IsValid = ($ ("#rbCar: radio:checked"). length > 0);
}
</script>
Display effect: