validating checkboxes

Results 1 to 2 of 2

Thread: validating checkboxes

  1. #1
    Join Date
    Dec 1969

    Default validating checkboxes

    hi <BR><BR>i have a list of 10 checkboxes next to student names on a page (and a drop down menu of subjects which is set to default --so user does not choose this) which the user has to choose from ---- whats the best way to return an error message if the user does not click on any of the checkboxes and presses SUBMIT . (preferably in ASP or VBscript)<BR><BR>On the page collecting the form information I have :<BR><BR>For each form_element_name in request.form<BR>if form_element_name &#060;&#062; Subject_Id then<BR>Participant_Index = Request.form (form_element_name)<BR><BR>so now in order to check whether at least one checkbox has been checked :<BR><BR>if Participant_Index = "" then<BR>response.write " you have not selected a participant" ?????<BR><BR> (i tried it but does not work ) any suggestions ??<BR>thanks<BR>smita

  2. #2
    Join Date
    Dec 1969

    Default RE: validating checkboxes

    I would normally use a naming convention similar to this for your circumstance.<BR>chkName1<BR>chkName2<BR>chkName3< BR>then on your submit page you would do this<BR>dim x &#039 for form elements<BR>dim i &#039 for counter<BR>i = 0<BR>for each x in request.form<BR> if request.form(x) = "on" then<BR> i = i + 1<BR> exit for<BR> end if<BR>next<BR><BR>if i &#062; 0 then<BR> &#039they selected at least one checkbox<BR>end if<BR><BR>cheers

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts