title: Disable submit if inputs empty - CodeIgniter
body: <p>Whine I submit empty form it insert an empty raw to my database. I am using CodeIgniter form validation also. How can I avoid this using CodeIgniter . Help Me Please.  ex- If from is empty no from submission. </p>
  
  <pre><code> $this-&gt;form_validation-&gt;set_rules('name', 'Name', 'trim|required|min_length[5]');
      // validate name
      $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'trim|required|valid_email');
      // validate email
      $this-&gt;form_validation-&gt;set_rules('phone', 'Phone Number', 'trim|required|min_length[10]|max_length[10]');
      // validate phone number
      $this-&gt;form_validation-&gt;set_rules('comment', 'Questions or Comments', 'required|min_length[10]');
      // validate phone number
      if ($this-&gt;form_validation-&gt;run() == FALSE)// if from validation failed load following pages from views
      {
          $this-&gt;load-&gt;view('template/header.php');
          $this-&gt;load-&gt;view('pages/contacts');
          $this-&gt;load-&gt;view('template/footer.php');
      }
      else // if from validation success load following pages from views
      {
          $this-&gt;load-&gt;view('template/header.php');
          $data['result']="Thank you for contacting us! We will reply you soon... ";
          $this-&gt;load-&gt;view('pages/contacts',$data);
          $this-&gt;load-&gt;view('template/footer.php');
      }
  </code></pre>
  
  <p>I am using required validation rule too please help me to fix this </p>
  
  <pre><code>&lt;?php echo form_open('form/contact') ?&gt;&lt;!--Creates an opening form
          ex :&lt;form method="post" accept-charset="utf-8" action="localhost/index.php/form(controller)/subscribe(function)" /&gt;--&gt;
          &lt;!-- Contact form Start --&gt;
          &lt;div class="span7"&gt;
              &lt;div class="box"&gt;
                  &lt;?php echo validation_errors('&lt;div class="notice marker-on-bottom bg-darkRed fg-white" id="bottom_form_error"&gt;', '&lt;/div&gt;'); ?&gt;
                      &lt;?php if(isset($result)){echo '&lt;div class="notice marker-on-bottom  bg-green fg-white"&gt;'.$result.'&lt;/div&gt;';}?&gt;
                      &lt;!-- Display Validation error massages  --&gt;
                  &lt;h6&gt;*All fields marked are required&lt;/h6&gt;
                      &lt;lable&gt;Your name*&lt;/lable&gt;
                      &lt;div class="input-control text" data-role="input-control"&gt;
                          &lt;input type="text" name="name" value="&lt;?php echo set_value('name'); ?&gt;" placeholder="type your name"&gt;
                          &lt;button class="btn-clear" tabindex="-1"&gt;&lt;/button&gt;
                      &lt;/div&gt;
                      &lt;lable&gt;Email*&lt;/lable&gt;
                      &lt;div class="input-control text" data-role="input-control"&gt;
                          &lt;input type="text" name="email" value="&lt;?php echo set_value('email'); ?&gt;" placeholder="type email address"&gt;
                          &lt;button class="btn-clear" tabindex="-1"&gt;&lt;/button&gt;
                      &lt;/div&gt;
                      &lt;lable&gt;Phone*&lt;/lable&gt;
                      &lt;div class="input-control text" data-role="input-control"&gt;
                          &lt;input type="text" name="phone" value="&lt;?php echo set_value('phone'); ?&gt;" placeholder="type phone number"&gt;
                          &lt;button class="btn-clear" tabindex="-1"&gt;&lt;/button&gt;
                      &lt;/div&gt;
                      &lt;lable&gt;Questions or Comments*&lt;/lable&gt;
                      &lt;div class="input-control textarea" data-role="input-control"&gt;
                          &lt;textarea name="comment" value="&lt;?php echo set_value('comment'); ?&gt;" &gt;...&lt;/textarea&gt;
                      &lt;/div&gt;
                      &lt;input name='contactus_status' type='hidden' value='no'/&gt;
                      &lt;input type="submit" value="Submit" class="info"&gt;
              &lt;/div&gt;
          &lt;/div&gt;
      &lt;?php  echo form_close(); ?&gt;&lt;!-- Contact form End --&gt;
  </code></pre>