Interface code:
Copy codeThe Code is 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>
Select the car type:
</Td>
</Tr>
<Tr>
<Td>
<Asp: RadioButtonList ID = "rbCar" runat = "server">
<Asp: ListItem Value = "1" Text = "Mercedes Benz"> </asp: ListItem>
<Asp: ListItem Value = "2" Text = "BMW"> </asp: ListItem>
<Asp: ListItem Value = "3" Text = "Audi"> </asp: ListItem>
<Asp: ListItem Value = "4" Text = ""> </asp: ListItem>
<Asp: ListItem Value = "5" Text = "Toyota"> </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 type of car! "
ForeColor = "Red" ClientValidationFunction = "rbCar_Validation"> </asp: CustomValidator>
</Div>
</Form>
Script code:Copy codeThe Code is 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>
</Head>
Display Effect: