Welcome Guest, Not a member yet? Register   Sign In
Send a date into form validation
#1

[eluser]copernicus[/eluser]
I have 3 input boxes on my page that take a month, day, and year. There are 4 sets of these, to take up to 4 dates. Is there a way I can set up a validation rule using the Form Validation library to send the values of these three inputs to a callback function all at once in order to check if it is a valid date?
#2

[eluser]SeasonedCoder[/eluser]
Just a suggestion: as an alternative you can use a JavaScript date picker, that will store a properly formatted date into one field, which you can easily validate.
#3

[eluser]copernicus[/eluser]
Yeah, I currently have something like that for when Javascript is enabled, but this is for when Javascript is disabled.
#4

[eluser]oddman[/eluser]
Interesting post, as I've been wondering how to get callbacks to make use of more than one field (at this point it seems impossible without some code hacks of the Form_Validation library, easily extended, however Tongue)

I would either:

a) Force the user to put it in one field, and give them a format example (ie. dd-mm-yyyy) or
b) Use a date picker as SeasonedCoder suggested

my 2c.
#5

[eluser]Thorpe Obazee[/eluser]
Code:
$date = $this->input->post('year').'-'.$this->input->post('day').'-'$this->input->post('month');

if (strtotime($date))
{
    return TRUE;
}
// set message
return FALSE;

There's nothing preventing you to use $this->input->post('key');




Theme © iAndrew 2016 - Forum software by © MyBB