1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

radiobutton validation

Discussion in 'ASP.NET' started by Carlos, Jun 11, 2009.

  1. Carlos

    Carlos New Member

    Hi! can anyone tell me how can i apply validation that one of the radio button must be selected among three radio buttons.

    It is quite easy to handle it through radiobuttonlist but the format appear in list.

    Please provide code in C#.

    thanx
     
  2. shabbir

    shabbir Administrator Staff Member

    If you make one selected then there is no way user can go without making a selection.
     
  3. Carlos

    Carlos New Member

    Yes, but i want that none of them should be selected, and the validation enforce user to select any one by himself.
     
  4. shabbir

    shabbir Administrator Staff Member

    Check for the value of them and atleast should be one.
     
  5. SaswatPadhi

    SaswatPadhi ~ Б0ЯИ Τ0 С0δЭ ~

    Like :

    Code:
    bool flag = false;
    
    flag = flag || radiobutton1.Checked;
    flag = flag || radiobutton2.Checked;
    flag = flag || radiobutton3.Checked;
    
    if( flag )
    {
          // continue execution
    }
    else
    {
          // prompt user to select a radiobutton
    }
     
    Last edited: Jun 12, 2009

Share This Page