checkbox validation

Discussion in 'Programming' started by kabucek, Dec 30, 2008.

  1. #1
    hello,

    i have this piece of code:





    
    
    
    		 <table border=0 cellspacing='0' cellpadding='0' class='paragraph' style=margin-top:20pt; width='1146'>
    		 
    		 
    		 
    		 <tr valign='top'>
          <td width='201'   height='26' align='left' $fieldLabelStyleString><div align='left'><font color='black'>Certyfying Organization</font>{$errorArray["cprorgname"]}</div>
    		<td  height='26' align=left width='945'><input type='text' name='otherInfoArray[cprorgname]' value='{$otherInfoArray['cprorgname']}'>
         	 Type of CPR  <font face='Arial, Helvetica, sans-serif' size='1' color='red'><em>*</em></font>
         	 Adult CPR   <input type='checkbox' name='otherInfoArray[cpradult]' value='{$otherInfoArray['cpradult']}'>
           Child CPR   <input type='checkbox' name='otherInfoArray[cprchild]' value='{$otherInfoArray['cprchild']}'>
           Infant CPR   <input type='checkbox' name='otherInfoArray[cprinfant]' value='{$otherInfoArray['cprinfant']}'>
          </td>
         </tr>
    		 
    		 
    		 
    		 <tr valign='top'>
          <td width='26'   height='26' align='left' $fieldLabelStyleString><div align='left'><font color='black'>Issue Date</font>{$errorArray["cprissuedate"]}</div>
    		<td  height='26' align=left width='26'><input type='text' name='otherInfoArray[cprissuedate]' value='{$otherInfoArray['cprissuedate']}'>
         	Expiration Date {$errorArray["cprexpdate"]}<input type='text' name='otherInfoArray[cprexpdate]' value='{$otherInfoArray['cprexpdate']}'> <br>
         	I attest that I have renewed my CPR certification and will submit documentation to that effect upon request.<font face='Arial, Helvetica, sans-serif' size='1' color='red'><em>*</em></font>
         	Yes   <input type='checkbox' name='otherInfoArray[cprattestyes]' value='{$otherInfoArray['cprattestyes']}'>
          No  <input type='checkbox' name='otherInfoArray[cprattestno]' value='{$otherInfoArray['cprattestno']}'>
            </td>
         </tr>
    		
            		
    		</table>
    
    		
    
           <DIV style='font-size:110%;text-align:left;margin-top:15pt;'>
                          <font face='Arial Black, Helvetica, sans-serif' size='5' color='black'>SUGGESTIONS/COMMENTS </font> 					
               </div>
    PHP:

    and I want for people to check the cprattestyes box and go next.
    if they do not check that box they will not go next

    thanks
     
    kabucek, Dec 30, 2008 IP
  2. Seraskier

    Seraskier Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Do you want something like this?
    http://75.181.72.104/checkvalid.html

    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function checkValid()
    {
    	var checked=document.getElementById("checkbox").checked;
    	if(checked==true)
    		{ document.getElementById("button").disabled=true; }
    	else
    		{ document.getElementById("button").disabled=false; }
    }
    </script>
    </head>
    
    <body>
    <input type="checkbox" onclick="checkValid()" id="checkbox" />
    <br />
    <input type="button" value="Submit" id="button" />
    </body>
    </html>
    
    Code (markup):
     
    Seraskier, Dec 30, 2008 IP
  3. kabucek

    kabucek Guest

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I want to have 2 checkboxes: Yes & No

    and I want the following actions:

    - if someone choose No - error message: " you need to accept"
    - if checkbox is not selected - error message: " you forgot to accept"

    i want the fieldname to be:

    otherInfoArray[cprattestyes] & otherInfoArray[cprattestno]


    thanks.
     
    kabucek, Dec 30, 2008 IP
  4. Seraskier

    Seraskier Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    http://75.181.72.104/checkvalid.html
    Is that what you wanted?

    In order to retrieve the code, just right click and hit view source.
    I added in a section of code for if you want to use radio buttons, which IMO is a better choice. That part of the code is commented out so in order to view it you must remove the <!-- and -->

    Jordan
     
    Seraskier, Dec 30, 2008 IP
  5. Seraskier

    Seraskier Peon

    Messages:
    53
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
  6. bhagwat_banna

    bhagwat_banna Peon

    Messages:
    38
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    thanks for the info
     
    bhagwat_banna, Jan 1, 2009 IP