php - display validation error message next to the textbox in codeigniter -


i'm newbie codeigniter.i want display error message next text box.my view file create.php contains following code.

  <?php          echo validation_errors();               //validation     echo form_open('news/create');  //create form      ?>  <div class="boxes">    <div class="common">      <div class="lables">         <label for="name">name</label>      </div>       <div class="text_boxes">         <input type="text" name="uname" /><div id="infomessage"><?php echo $message;?></br>     </div> </div>` 

and below controller model:

 public function create() {     $this->load->helper('form');     $this->load->library('form_validation');      $data['title'] = 'insert items';      $this->form_validation->set_rules('uname','required|min_length[6]|max_length[15]');     $this->data['message'] = enter name;     $this->form_validation->set_rules('uaddress','enter address','required');     $this->form_validation->set_rules('email','enter emailid','required');     $this->form_validation->set_rules('mobile','enter mobile number','required');       if ($this->form_validation->run() === false)     {         $this->load->view('templates/header', $data);         $this->load->view('news/create');         $this->load->view('templates/footer');      }     else     {         $this->news_model->set_news();         $this->load->view('news/success');     }     /** view details **/     $data['user_data'] = $this->news_model->get_details();     $data['title'] = 'database details';      $this->load->view('templates/header');   //used call view file(header) in templates/header     $this->load->view('news/index', $data);         //used call view file(index) ie:news/index     $this->load->view('templates/footer');              //used call view file(footer) ie:templates/header     /**     end **/ } 

but know #infomessage show after username field . don't know how display error message in custom place.

kindly me solve this!!

edit: after add

 <input type="text" name="uname"  value="<?php echo set_value('uname'); ?>" />   <div id="infomessage"><?php echo form_error('uname'); ?></div></br>  

this code show below image:

my output

if read ci documentation find answer.

replace line this

<input type="text" name="uname"  value="<?php echo set_value('uname'); ?>" /><div id="infomessage"><?php echo form_error('uname'); ?></div></br> 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -