[eluser]HooJee[/eluser]
Hi Guys
I am trying to valiate my form using the form_validation controller but everytime I submit my form nothing happens. Code below:
// HTML
Code:
<?php echo validation_errors(); ?>
<form 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|min_length[1]', 'required');
$this->form_validation->set_rules('email', 'Email|valid_email', 'required');
$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');
}
}