CodeIgniter Forums
Validate Drop Down Selections - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Validate Drop Down Selections (/showthread.php?tid=33598)

Pages: 1 2


Validate Drop Down Selections - El Forum - 09-01-2010

[eluser]Petsoukos[/eluser]
[quote author="iConTM" date="1283386876"]Does the link to your css file work?
Try view source and copy paste the css link in your browser.[/quote]

Yes it spits out the script...


Validate Drop Down Selections - El Forum - 09-01-2010

[eluser]iConTM[/eluser]
Ah maybe it's the version of jquery?

I used jquery-1.3.2.min.js

I noticed that some jquery plugins only work with a certain version of jquery installed.


Validate Drop Down Selections - El Forum - 09-01-2010

[eluser]Petsoukos[/eluser]
I have the latest in use.


Validate Drop Down Selections - El Forum - 09-01-2010

[eluser]iConTM[/eluser]
try using jquery-1.3.2.min.js


Validate Drop Down Selections - El Forum - 09-02-2010

[eluser]Petsoukos[/eluser]
Well I mixed up the datepicker utilities. Actually I've used this http://javascriptcalendar.org/javascript-date-picker.php this was causing the problem I've mentioned.

The one you are referring is working. You said the textfield+datepicker is more userfriendly. One click only. But I think otherwise. With this date picker I have to click 25 times to get to my year of birth + 1 to select the date. ;-)


Validate Drop Down Selections - El Forum - 09-02-2010

[eluser]Petsoukos[/eluser]
Hm... I've got it running with drop down and it validates correctly as far I can tell.

I check the validation from on point only
Code:
$this->form_validation->set_rules('year', 'Year', 'trim|required|numeric|callback_datechecker');
$this->form_validation->set_rules('month', 'Month', 'trim|required|numeric');
$this->form_validation->set_rules('day', 'Day', 'trim|required|numeric');
The form validation on the year input.

The callback method:
Code:
function DateChecker() {
$y = $this->input->post('year');
$m = $this->input->post('month');
$d = $this->input->post('day');
    if(checkdate($m, $d, $y)) {            
        return true;
    } else {
        $this->form_validation->set_message('datechecker', 'Invalid Date!');
        return false;
    }
}

Can someone else confirm this? When for example I enter an erroneous date like 2010 02 31 (31 Feb ;-P ) I get the error message. Or any invalid date. If someone was so kind to review it for any loopholes or a trick to bypass it I would be greatfull.

Thanks!