【发布时间】:2021-09-17 17:05:00
【问题描述】:
如何在 codeigniter 中验证多个日期格式
这是我的模式:
/^([1-9]|1[0-9]|2[0-9]|3[0-1])\/([1-9]|1[0-2])\/202[0-5]$/
Codeigniter 代码:
$this->form_validation->set_rules('mir_date', 'MIR Date', 'required|regex_match[/^([1-9]|1[0-9]|2[0-9]|3[0-1])\/([1-9]|1[0-2])\/202[0-5]$/]', [
'required' => 'MIR Date',
'regex_match' => 'Invalid MIR Date'
]);
模式应接受以下日期格式d/m/yyyy、dd/mm/yyyy、dd/m/yyyy、d/mm/yyyy
【问题讨论】:
-
你确定你的语法没有关闭吗?
->->?regex_match[//.../]?尝试$this->form_validation->set_rules('mir_date', 'MIR Date', 'required|regex_match[/^([1-9]|1[0-9]|2[0-9]|3[0-1])\/([1-9]|1[0-2])\/202[0-5]$/]', [作为第一行。如果它不起作用,可能是由于|,您需要将其声明为单独的函数或定义为数组。
标签: php regex codeigniter