[eluser]Mat-Moo[/eluser]
I'm trying to do a contact form, and learning as I go
But I've hit a small issue :-
Code:
$rules['fname'] = "trim|required|min_length[5]|max_length[48]|xss_clean";
$rules['femail'] = "trim|required|valid_email";
$rules['fcomments'] = "trim|required|min_length[16]|max_length[1024]|xss_clean";
$this->validation->set_error_delimiters('<li>', '</li>');
$this->validation->set_rules($rules);
# set data
$data["fname"] = "Name";
$data["femail"] = "E-mail address";
$data["fcomments"] = "Comments";
$this->validation->set_fields($data);
$data["fname"] = array('name' => 'fname', 'id' => 'fname', 'class' => ($this->validation->fname_error<>"") ? 'textbox error' : 'textbox', 'value' => $this->validation->fname);
$data["femail"] = array('name' => 'femail', 'id' => 'femail', 'class' => 'textbox', 'value' => $this->validation->femail);
$data["fcomments"]=array('name' => 'fcomments', 'rows' => 5, 'cols' => 80, 'value' => $this->validation->fcomments);
As you can see in $data[fname] I'm trying to set the class of the box depending on the bases of the validation (textbox) or (textbox error). But I can't work out how you validate, or check the validation of a single field? I'm doing it this way as my form uses the form_input($fname) rather than a basic html form.
Clues and inputs aer welcome