Go4Expert (http://www.go4expert.com/)
-   ASP.NET (http://www.go4expert.com/forums/asp-net/)
-   -   radiobutton validation (http://www.go4expert.com/forums/radiobutton-validation-t17950/)

Carlos 12Jun2009 02:53

radiobutton validation
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#.


shabbir 12Jun2009 09:41

Re: radiobutton validation
If you make one selected then there is no way user can go without making a selection.

Carlos 12Jun2009 15:30

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

shabbir 12Jun2009 15:41

Re: radiobutton validation
Check for the value of them and atleast should be one.

SaswatPadhi 12Jun2009 18:17

Re: radiobutton validation
Like :

Code: C#

bool flag = false;

flag = flag || radiobutton1.Checked;
flag = flag || radiobutton2.Checked;
flag = flag || radiobutton3.Checked;

if( flag )
      // continue execution
      // prompt user to select a radiobutton

All times are GMT +5.5. The time now is 19:21.