validating a form with that has an input type="date" which takes input mm/dd/yyyy however if i var_dump the results it comes out as yyyy-mm-dd.
1 do I validate the input type "mm/dd/yyyy", or do i validate "yyyy-mm-dd".
---im assuming I validate what the var_dump gives me which is yyyy-mm-dd.
2 More importantly I am having a hard time finding out the simplest way of going about validating date.
---I am not sure how to go about validating the date without going through by hand and checking every single date. Is there some built in functions that I could use, and how would I go about implementing that in with my CI form validations I already have.
function check_registration($post_data)
{
// Validations:
// first_name
$this->form_validation->set_rules('first_name', 'First Name', "trim|required");
// last_name
$this->form_validation->set_rules('last_name', 'Last Name', "trim|required");
// email
$this->form_validation->set_rules('email', 'Email', "trim|required|valid_email|is_unique[users.email]");
// password
$this->form_validation->set_rules('password', 'Password', "trim|required|min_length[6]");
// confirm_password
$this->form_validation->set_rules('confirm_password', 'Confirm Password', "trim|required|matches[password]");
// DOB
$this->form_validation->set_rules('DOB', 'Date of Birth', "trim|required");
// run validations:
if ($this->form_validation->run() === False)
{
// set flash data errors
$this->session->set_flashdata("reg_first_name_error", form_error('first_name'));
$this->session->set_flashdata("reg_last_name_error", form_error('last_name'));
$this->session->set_flashdata("reg_email_error", form_error('email'));
$this->session->set_flashdata("reg_password_error", form_error('password'));
$this->session->set_flashdata("reg_confirm_password_error", form_error('confirm_password'));
$this->session->set_flashdata("reg_DOB_error", form_error('DOB'));
redirect('/');
}
// No errors:
else
{
$this->insert($post_data);
redirect('/success');
}
}
Thanks in advance.
-Ants