![]() |
form validation date and time - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: form validation date and time (/showthread.php?tid=13736) |
form validation date and time - El Forum - 12-03-2008 [eluser]TheoR74[/eluser] what is the best way to setup on a form a date/time field and have it validated? Thanks. form validation date and time - El Forum - 12-03-2008 [eluser]Rey Philip Regis[/eluser] For me the simpliest way of doing it, is to find a javascript library to do it for me..There are lots of javascript libraries on the web and on of them is DOJO http://dojotoolkit.org Actually if its possible I don't really like to code forms with validation manually cause it takes time rather than look for a javascript library, then find the one you need and use it in your application. If you really want to do it manually why not use drop down boxes for the month - day - year - hour - minutes. All drop down boxes has a default value of blank meaning "" no value. Then use CI's form validation with "required" parameter. Hope that helps.. form validation date and time - El Forum - 12-03-2008 [eluser]fesweb[/eluser] Here is a very good and flexible js datepicker. Depending on your needs, you'll likely still want to do server-side validation to be thorough, using callback functions to supplement the form_validation library. Good luck. form validation date and time - El Forum - 09-10-2009 [eluser]Unknown[/eluser] For me fastest way to do it using date picker using jquery used to get date if you do that u can force user to enter date/time of your format. Or other way to do it is Regular Expression :coolsmile: form validation date and time - El Forum - 09-11-2009 [eluser]Kamarg[/eluser] I make use of the jquery date picker like the others have suggested. However, since we all know that you can't trust user input, you still need to validate the date on the server side. For that I've extended the form validation library and added the date rule below. There are better date regex validation functions out there but for my purposes it doesn't matter if the user gives me a date such as 99/99/0001 as the date fields are merely display information and not used for any type of logic. Code: function date($str) { |