Jump to content

Recommended Posts

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>

         

 

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

Link to comment
https://forums.phpfreaks.com/topic/138883-checkbox-validation/
Share on other sites

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.

 

Link to comment
https://forums.phpfreaks.com/topic/138883-checkbox-validation/#findComment-726540
Share on other sites

try this...

 

<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='yes' value='yes'>
      No  <input type='checkbox' name='no' value='no'>
        </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
$yes = $_POST['yes'];
$no = $_POST['no'];

if ($yes == "" || $no == "no")
echo "you need to accept";

if ($yes == "" || $no == "")
echo "you forgot to accept";

?>

Link to comment
https://forums.phpfreaks.com/topic/138883-checkbox-validation/#findComment-727179
Share on other sites

Honestly, that sounds like a validation that should be done on the JS side of things. Of course have the PHP validation, but if I was filling out the form I'd definitely want a JS validation alert or something.

 

You should have both incase the user turns off JS.

Link to comment
https://forums.phpfreaks.com/topic/138883-checkbox-validation/#findComment-728196
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.