asp.net - Customvalidator: Check if radiobuttonlist contains a selected item -


I have a radiobutton list with two items, yes or no. The Radiobotton list controls have a custom validator that needs server validation functions and JavaScript clientvalidationfunction. Could you help me? The work works in this message, but only when I actually select one of the two lists, when a list is chosen, verification leaves my radiootonist control.

  function ValidateRadioButtonList (source, argument) {var RBL = document. GetElementById (source.controltovalidate); Var radioban list = RBL.Get Elements biatagnam ("input"); Var counter = 0; Var for atLeast = 1 (var i = 0; i & lt; radiobuttonlist.length; i ++) {if (radioobuttonlist [i] checked) {counter ++; }} If (atLeast = counter) {arguments.IsValid = true; Return logic. } Arguments.IsValid = false; Return logic. }  

Edit: Code relevant to comments

  & lt; Asp: button id = "btnSubmit" runat = "server" text = "submit" CssClass = "btnNormal" validity of reasons = "true" /> & lt; Asp: CustomValidator runat = "Server" Client Validity Function = "ValidateButton List" Onverwerville = "Radiabutan List Server Validation" id = "cvRadioButtonList" font-bold = "True" font-size = "medium" error message = "business critical" ControltoValidate = "RLB Business Critical" & gt; * & Lt; / ASP: CustomValidator & gt; & Lt; ASP: RadiButton LIST ID = "RLB Business Critical" Runat = "Server" Repeat Layout = "Flow" Repeat Direction = "Horizontal" tabindex = "4" & gt; & Lt; Asp: ListItem text = "yes" value = "1" /> & Lt; Asp: ListItem text = "no" value = "0" /> & Lt; / ASP: RadioButtonList & gt;  

Behind the code:

  The public sub-radio button list validates the server (as the sender of the object, argues in the form of ServerValidateEventArgs) if rblBusinessCritical .SelectedValue = "-1" then args .IsValid = False cvRadioButtonList.ErrorMessage = "Business Important Needs" Exit sub-other logic. ISIIDID = True And If And All  

Have set up?

EDIT: Have you set the validity due to the reality of your submit button / radio button? Please provide some code from your aspx-page.


Comments