Skip navigation
Currently Being Moderated

text box validation

Mar 31, 2011 9:25 AM

i have a form with 7 seven check boxes. If the user does not check at least one of them one. I do not want the form to submit and alert the user to check at least one check box. I am  beginner - intermeidate at best with cf8 and have not  found a solution yet to do the job, Please see code and form below. Any help is appreicated MUCH!  thanks jim

 

<script type="text/javascript" language="javascript">
function hello(){alert('Hi');return false;}
function checkCheckBoxes(theForm) {
alert('Hello you must check at least one check box. ');
if (
theForm.fundamentals.checked == false &&
theForm.reports.checked == false &&
theForm.report2.checked == false &&
theForm.pms.checked == false &&
  theForm.map.checked == false &&
   theForm.mms.checked == false &&quot;
    theForm.rol.checked == false &&
    theForm.complete.value=='NO')
{
  alert ('You didn\'t choose any of the checkboxes!');
  return false;
} else { 
  return true;
}

 

 

<cfform name="mobReg1" id="mobReg1" action="http://www.crab.wa.gov/Technology/Mobility/pgs/confirm_reg2.cfm" method="post" onsubmit="return hello();">

 

<table width="490" border="1" style="color:#000000; border-collapse:collapse;">
                        <tr bgcolor="#eeeeeee">
                          <td><input type="checkbox" name="fundamentals" value="Session 1 Mobility 3.0.4 Fundamentals - 25 May @ 8:30AM- 11:30AM" /></td>
                          <td>Session 1 Mobility 3.0.4 Fundamentals</td>
                          <td>25 May @ 8:30AM- 11:30AM</td>
                        </tr>
                        <tr  bgcolor="#eeeeee">
                          <td><input type="checkbox" name="reports" value="Session 2 Mobility Custom Reports - 25 May @ 12:45PM - 4:00PM" /></td>
                          <td>Session 2 Mobility Custom Reports</td>
                          <td>25 May @ 12:45PM - 4:00PM</td>
                        </tr>
                        <tr bgcolor="#ffd940">
                          <td><input type="checkbox" name="pms" value="Session 3 Mobility Pavement Management - 26 May @ 8:30AM - 10:30AM"/></td>
                          <td>Session 3 Mobility Pavement Management</td>
                          <td>26 May @ 8:30AM - 10:30AM</td>
                        </tr>
                        <tr bgcolor="#ffd940">
                          <td><input type="checkbox" name="map" value="Session 4 Mobility Map - 26 May @ 10:45AM - 12:00PM"/></td>
                          <td>Session 4 Mobility Map </td>
                          <td>26 May @ 10:45AM - 12:00PM</td>
                        </tr>
                        <tr bgcolor="#ffd940">
                          <td><input type="checkbox" name="report2" value="Session 5 Custom Reports Level 2 - 26 May @ 1:15PM - 4:00PM" /></td>
                          <td>Session 5 Custom Reports Level 2</td>
                          <td>26 May @ 1:15PM - 4:00PM</td>
                        </tr>
                        <tr bgcolor="#eeeeee">
                          <td><input type="checkbox" name="mms" value="Session 6 Maintenance Management Workshop - 27 May @ 8:30AM- 11:30AM" /></td>
                          <td>Session 6 Maintenance Management Workshop</td>
                          <td>27 May @ 8:30AM- 11:30AM</td>
                        </tr>
                        <tr bgcolor="#eeeeee">
                          <td><input type="checkbox" name="rol" value="Session 7 RAP Online - 27 May @ 12:45PM - 4:00PM" /></td>
                          <td>Session 7 RAP Online</td>
                          <td>27 May @ 12:45PM - 4:00PM</td>
                        </tr>
                      </table>

 

 

<cfinput type="submit" name="submit" value="Register">
                      <cfinput type="reset" name="Reset " value="Reset Form">
                    </div>
                  </fieldset>
                </cfform>

chkboxtable.PNG

 

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points