I'm using codeigniter with PHP
.
I'm using following form,
<?php
echo form_open('/register/create_new', $form_params);
?>
DOB: <input type="text" id="dob" name="reg[dob]">
<input type="submit" value="Create Account" />
</form>
here, #dob
is in dd-mm-yyyy
format.
my validation code is,
array(
'field' => 'reg[dob]',
'label' => 'DOB',
'rules' => 'required'
)
How can i set the rules
for correct date validation?
you can do it with regex
$this->form_validation->set_rules('reg[dob]', 'Date of birth', 'regex_match[(0[1-9]|1[0-9]|2[0-9]|3(0|1))-(0[1-9]|1[0-2])-\d{4}]');