[eluser]David Johansson[/eluser]
You have som errors... I don't know if I found all of them, but here is you code with some improvements:
// HTML
Code:
<?php echo validation_errors(); ?>
<form action="/*change tho the path to your controller*/" method="post" id="contactForm">
<div class="padding"> Your Name: </div>
<input type="text" name="name" id="name" size="35"/> <br />
<div class="padding"> Your Email: </div>
<input type="text" name="email" id="email" size="35"/> <br />
<div class="padding"> Comments: </div>
<textarea id="comments" name="comments" ></textarea> <br />
<input type="submit" id="submit" value="Submit"/>
<span></span>
</form>
// Controller
Code:
function contact() {
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('name', 'Name', 'required|min_length[1]');
$this->form_validation->set_rules('email', 'Email', 'required|valid_email');
$this->form_validation->set_rules('comments', 'Comments', 'required|min_length[5]');
if ($this->form_validation->run() == FALSE) {
$this->load->view('ajax/contact');
} else {
$this->load->view('formsuccess');
}
}