Jump to content

alert once submit button clicked and checkbox is empty


robert_gsfame

Recommended Posts

if(isset($_POST['submit']))
{
   if(isset($_POST['checkbox']))
   {
      //proceed
   }
   else
   {
      $checkBoxFlag = true;
   }
}

//at your form or wherever
if($checkBoxFlag)
{
   echo 'You must check the checkbox';
}
//form code here

if(isset($_POST['submit']))
{
   if(isset($_POST['checkbox']))
   {
      //proceed
   }
   else
   {
      $checkBoxFlag = true;
   }
}

//at your form or wherever
if($checkBoxFlag)
{
   ?>
      <script type="text/javascript">
      alert("You must check the checkbox");
      </script>
   <?PHP
}
//form code here

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.