Jump to content

checkbox validation help plz


delickate

Recommended Posts

hi guys,

  i need check box validation. if i didn't check it then it must alert error "please agree term and condition".

  if it checked it it should not return and thing.

  i m using following code

function checkBoxes(fld)

  {

if (!fld.checked)

  {

    error ="Please agreed to the Terms and Conditions!";

        return error;

  }

return true;

}

 

it works well. when i didnt check it return error.but if i check it. it again lert "true".

i need to skip return true.if i check it it didnt show alert.

any one know how to?

 

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

You dont need a function for such a small thing

 

Try:

 

<?php if(isset($_POST['checkbox'])){ checkbox is checked } else { its not checked } ?>

 

 

or:

function is_checked($checkbox){

    $checkbox = (isset($checkbox)) ? true : false;

     if($checkbox){ return true; }
    else { return false; }

  // OR return $checkbox
  
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.