I am using PHP CodeIgniter. I have kept validation in a function. I do not know the validation rule for date and time calendar in CodeIgniter. Can anyone give me an idea?
My code is :
$this->ref_valid_rules = array(
array('field' => 'meeting_heading',
'label' => 'meeting heading',
'rules' => 'trim|required'),
array('field' => 'meeting_agenda',
'label' => 'meeting agenda',
'rules' => 'trim|required'),
array('field' => 'venue',
'label' => 'venue',
'rules' => 'trim|required'),
array('field' => 'date',
'label' => 'date time',
'rules' => 'required') );
You can try
$this->form_validation->set_rules('date', 'date time', 'regex_match[(0[1-9]|1[0-9]|2[0-9]|3(0|1))-(0[1-9]|1[0-2])-\d{4}]');
http://www.formget.com/codeigniter-form-validation-date/
and other answers Codeigniter - Date format - Form Validation
Date validation in codeigniter
or you can try the set validation rules using callbacks
function regex_date($date) {
$data = preg_match('@^Jan|Feb|Mar|Apr|May|June|July|Aug|Sept|Oct|Nov|Dec-[0-9]{2}-[0-9]{4} [0-9]{2}:[0-9]{2}:[0-9]{2}$@', $date);
return $data;
}
the function will return true or false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With