Welcome Guest, Not a member yet? Register   Sign In
Move View Controller Files
#1

[eluser]razerone[/eluser]
The Validating User Guide does not say much to help me. Is there a method of validation that will suite my form below

I need to add a class of has-error to my form-group div. If input field are not filed out correct or missing.

And also a class of has-success to form-group div If form input filed in correct.

Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Contactpage extends MX_Controller {

function index() {

  $this->load->helper('form');
  $this->load->library('javascript');


  $this->load->view('header');
  $this->load->view('contact-us');
  $this->load->view('footer');

}

function messagesent() {
  $this->load->helper('form');

  $this->load->library('email');

  $this->email->from($this->input->post('email'), $this->input->post('name'));
  $this->email->to('[email protected]');

  $this->email->subject($this->input->post('subject'));
  $this->email->message($this->input->post('message'));

  if($this->email->send()) {
  
   $this->load->view('header');
   $this->load->view('messagesent');
   $this->load->view('footer');
  }
  else {

   show_error($this->email->print_debugger());

  }
}

}

Code:
<form id="contact-form" acti echo base_url('contactpage/messagesent');?>" method="post" role="form">
<div id="contact-form" role="form">
<div class="form-group">
&lt;input name="name" type="text" id="focusedInput" class="form-control " placeholder="Enter Name"&gt;
</div>
<div class="form-group">
&lt;input name="email" type="text" id="focusedInput" class="form-control" placeholder="Enter Email"&gt;
</div>
<div class="form-group">
<select name="subject" id="focusedInput" class="form-control" >
<option selected="">Choose One:</option>
<option>Feedback</option>
<option>Suggestion</option>
<option>Question</option>
<option>Other</option>
</select>
</div>
<div class="form-group">
&lt;textarea name="message" type="text" class="form-control" rows="4" placeholder="Message" name="message"&gt;&lt;/textarea>
</div>
<div class="pager">
<button type="submit" class="btn btn-primary">Submit</button>
<button type="reset" class="btn btn-danger">Reset</button>
</div>
</div>
&lt;/form&gt;
#2

[eluser]noideawhattotypehere[/eluser]
Use client side validation for that, no point in doing it via server side
#3

[eluser]razerone[/eluser]
[quote author="noideawhattotypehere" date="1381927912"]Use client side validation for that, no point in doing it via server side[/quote]

you mean just straight to form rather than using controllers.

I add the normal js but every time I clicked send it wouldn't go through JS.

I have HMVC setup.

Sample Layout

index.php

assets / images

assets / js

assets / css

application / controllers / header.php

application / controllers / home.php <-- set as default home

application / controllers / footer.php <-- JavaScript Add on Bottom Of Footer

application / modules / contact / controllers / contactpage.php

application / modules / contact / views / contact-us.php




Theme © iAndrew 2016 - Forum software by © MyBB