Validate Drop Down Selections |
[eluser]Petsoukos[/eluser]
Hi, I want to validate a date formed with drop down selections. I have three different drop down menus. (Year, Month, Day) When it is submitted the controller receives three different POSTS. One for each drop down. I can make the validation very easy with PHP checkdate() function: Code: $y = $this->input->post('y');
[eluser]iConTM[/eluser]
I would make 1 field to input the date. If you want to use CI's formvalidation class you can do something like this: Code: $this->form_validation->set_rules('date', 'Date', 'callback_date_check'); Code: function date_check ($value)
[eluser]Petsoukos[/eluser]
That's the thing. I don't want to use a text input field. I would like to have the drop downs... every one is using drop downs.
[eluser]iConTM[/eluser]
The date check finetuned: Code: function date_check ($value)
[eluser]iConTM[/eluser]
[quote author="Petsoukos" date="1283378428"]That's the thing. I don't want to use a text input field. I would like to have the drop downs... every one is using drop downs.[/quote] I don't agree about that I notice that the dropdowns are more and more replaced by textfields together with a datepicker. is more userfriendly (only one click) jquery datepicker: http://www.kelvinluck.com/assets/jquery/...r/v2/demo/
[eluser]iConTM[/eluser]
or: Code: // run the validation on 1 of the dropdowns Code: function date_check ($value)
[eluser]Petsoukos[/eluser]
I tried the jQuery datepicker but for some odd reason when I click on the text field it just displays it in the main body of the page and not as a "pop-out" frame. Can't figure out how to make it work.
[eluser]iConTM[/eluser]
You have to include the css: http://www.kelvinluck.com/assets/jquery/...Picker.css
[eluser]Petsoukos[/eluser]
I didn't forget... Code: <link rel="stylesheet" href="<?php echo base_url();?>application/views/templates/default/css/datePicker.css" type="text/css" media="screen" charset="utf-8" /> This is the code from my header. Maybe the CSS file has to be on a different location...
[eluser]iConTM[/eluser]
Does the link to your css file work? Try view source and copy paste the css link in your browser. |
Welcome Guest, Not a member yet? Register Sign In |