Radio button validation

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jay123
    New Member
    • Sep 2008
    • 121

    Radio button validation

    hello,
    i have two radio buttons in my page and need user to select one out of them, else an error message is displayed. i know some might think why not use radiobuttonlist ?? due to requirement i cant.

    any help with code will be appreciated..

    my code..

    Code:
    <asp:RadioButton ID="csamaintv" runat="server" GroupName="csamaintg" />
                                             <asp:RadioButton ID="csamaintr" runat="server" GroupName="csamaintg" />
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    Why not use an if section to test it when posting the page?????

    Comment

    • jay123
      New Member
      • Sep 2008
      • 121

      #3
      Originally posted by Shashi Sadasivan
      Why not use an if section to test it when posting the page?????
      i have like 70 pairs of radio button in my page, is their any way i can use any validator for this problem..

      Comment

      • Shashi Sadasivan
        Recognized Expert Top Contributor
        • Aug 2007
        • 1435

        #4
        Originally posted by jay123
        i have like 70 pairs of radio button in my page, is their any way i can use any validator for this problem..
        If all the radio buttons in the form are to be linked to a single group then you can do a simple for loop on all controls on the form, and check that, atleast one is checked.
        if however you have more than one group, then you will have to sort it out from the rest (still looping through all radio buttons in the form)

        Comment

        Working...