[eluser]RecoilUK[/eluser]
Hi guys
Actually, I decided that's not very good, so am using the callback functionality after all, but have another problem, here is my callback function ...
Code:
function _check_postcode() {
$this->load->library('form_validation');
$postcode1 = $this->input->post('postcode1');
$postcode2 = $this->input->post('postcode2');
if($postcode1 == '' && $postcode2 == '') {
$this->form_validation->set_message('_check_postcode', 'This is a required field!.');
return $postcode1;
}
if($postcode1 == '' || $postcode2 == '') {
$this->form_validation->set_message('_check_postcode', 'Both field\'s are required!.');
return FALSE;
}
if(strlen($postcode1) < (3)) {
$this->form_validation->set_message('_check_postcode', 'Part 1 of this field must contain 3 characters!.');
return FALSE;
}
if(strlen($postcode1) > (4)) {
$this->form_validation->set_message('_check_postcode', 'Part 1 of this field must contain no more than 4 characters!.');
return FALSE;
}
if(strlen($postcode2) < (3)) {
$this->form_validation->set_message('_check_postcode', 'Part 2 of this field must contain 3 characters!.');
return FALSE;
}
if(strlen($postcode2) > (4)) {
$this->form_validation->set_message('_check_postcode', 'Part 2 of this field must contain no more than 4 characters!.');
return FALSE;
}
if(! preg_match("/^([a-z0-9])+$/i", $postcode1 . $postcode2)) {
$this->form_validation->set_message('_check_postcode', 'This field can only contain alphanumeric characters!.');
return FALSE;
}
}
Now when the field passes all checks, its works as it should and does not display an error message, the problem is, when other fields fail there checks, the postcode field does not get repopulated.
Any ideas?