Welcome Guest, Not a member yet? Register   Sign In
Aaargh!! What Am I Doing Wrong With This Callback?
#1

[eluser]Phil Norton[/eluser]
Right, I've done callbacks before with no problems, but what should be very simple is taking me an age to get working. Perhaps it's a case of looking at the same thing for too long, so hopefully someone out here can spot what I'm doing wrong!!

In my Controller:
Code:
$rules['start_time'] = "required|callback_timeCheck";

And then the validation in the same Controller:
Code:
function timeCheck($time) {
if (!ereg("^([0-1][0-9]|[2][0-3]):([0-5][0-9])$", $time)) {
        $this->validation->set_message('timeCheck', 'Please Enter All Times In 24-Hour Format eg 09:00');
        return FALSE;        
    } else {
        return TRUE;
    }
}

If I leave the field blank, CI's "required" validation works and throws up an error. But if I type anything in the box, the error isn't being triggered. However, if I use the regex to check the string entered by doing this when I submit the form, I get the correct result so I know the regex is correct:
Code:
if (!ereg("^([0-1][0-9]|[2][0-3]):([0-5][0-9])$", $this->input->post('start_time'))) {
    echo "INCORRECT FORMAT";
} else {
    echo "CORRECT FORMAT";
}



Like I said, it's possible that I've been staring at it for so long now that the very obvious answer is laughing at me whilst staying hidden from my eyes!!

Any help would be gladly appreciated!

Phil


Messages In This Thread
Aaargh!! What Am I Doing Wrong With This Callback? - by El Forum - 07-31-2008, 08:39 AM
Aaargh!! What Am I Doing Wrong With This Callback? - by El Forum - 07-31-2008, 11:06 AM
Aaargh!! What Am I Doing Wrong With This Callback? - by El Forum - 07-31-2008, 11:08 AM
Aaargh!! What Am I Doing Wrong With This Callback? - by El Forum - 07-31-2008, 11:11 AM
Aaargh!! What Am I Doing Wrong With This Callback? - by El Forum - 07-31-2008, 02:01 PM
Aaargh!! What Am I Doing Wrong With This Callback? - by El Forum - 08-04-2008, 03:24 PM



Theme © iAndrew 2016 - Forum software by © MyBB