I noticed that one of the benifits of RequiredFieldValidator is that you no longer have to post back to the server to do the validation however with the checkbox control, the only way I got validation to work was to do an If statement. I have 2 checkboxes and if neither of the 2 were checked, then the user gets an error message (label). But in order to do so, I had to put this if statement on submission of the page so it posts thus giving me the validation error.
I don't see how you can use RequiredFieldValidator if you have 2 checkboxes and at least one checkbox has to be checked but not both can be checked at the same time. If both had to be checked then I could use RequiredFieldValidator but that isnt' the case
so is there a way to do a validation client?
Here is how I did it but this requires a post and I thought that one of the benefits of .Net was to get around having to post back to validate sometimes....
Sub Button_Click( s As Object, e As EventArgs )
Dim Conn as SQLConnection
Dim strInsert as String
Dim cmdSQL as SQLCommand
If Not (Full_Time.Checked OR Part_Time.Checked) Then
Error_BothChecked.Text="<FONT FACE=""ARIAL"" COLOR=RED SIZE=2><B>You must check <U>at least one</U> checkbox</B></FONT>"
Else If (Full_Time.Checked AND Part_Time.Checked) Then
Error_BothChecked.Text="<FONT FACE=""ARIAL"" COLOR=RED SIZE=2><B>You must <U>only check one</U> checkbox</B></FONT>"
maybe this is the only way in this circumstance but I think there must be a way to do this with some of the checkbox properties
I thought of using a checkboxlist but this seems to work fine already in reference to how I did it above