CodeIgniter Forums
Problem Setting Error Message For Form - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Problem Setting Error Message For Form (/thread-54611.html)



Problem Setting Error Message For Form - El Forum - 09-17-2012

[eluser]Swayam[/eluser]
Dear All,

Please help me with this..i am new in codeigniter..i have a registration form where i have 7 fields ..i m validating all the fields with set_rules...but when user press submit without entering information..it shows field is required individually ..i want a single message if all the fields left blank..
Code:
$this->form_validation->set_rules('uname','Username','required|min_length[5]|max_length[12]');
  $this->form_validation->set_rules('pass','Password','required');
  $this->form_validation->set_rules('fname','Full Name','required');
  $this->form_validation->set_rules('emailid','Email id','required|valid_email');
  $this->form_validation->set_rules('address','Address','required');
  $this->form_validation->set_rules('city','City','required');
  $this->form_validation->set_rules('contact','Contact No.','required');
  $this->form_validation->set_message('required',"Error Message");
  
  if($this->form_validation->run() == FALSE)
  {
   $data['error_message'] = validation_errors();
   $this->load->view("registration",$data);
  }
  else
  {
                  echo "valid";
                }
..how can we do this..??