Validation Thread - 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: Validation Thread (/showthread.php?tid=4815) |
Validation Thread - El Forum - 12-17-2007 [eluser]cinewbie81[/eluser] Hi all, Can i have something like this for my validation: Code: If Dropdown menu select item == '0' then Anyone ? Validation Thread - El Forum - 12-17-2007 [eluser]Developer13[/eluser] Have you tried? Validation Thread - El Forum - 12-17-2007 [eluser]Nick Husher[/eluser] The answer is yes; at least I'm 99% sure it is. Validation Thread - El Forum - 12-17-2007 [eluser]Developer13[/eluser] I think the question would be better answered if the author posted some specific code along with the specific problems they have with that code. Validation Thread - El Forum - 12-17-2007 [eluser]cinewbie81[/eluser] Ignored my post above, and look at the following code: I have a select box with following value: Code: <select name="gender" id="gender"> In my controller i want something like this: Code: function validation() what validation rules should i put for gender select box ?? I dont think rules['gender'] = 'required' is the correct one .. anyone ? Validation Thread - El Forum - 12-17-2007 [eluser]Nick Husher[/eluser] The way I'd do it (and there might be a better way) is to create a simple callback that checks that: Code: ... Validation Thread - El Forum - 12-17-2007 [eluser]cinewbie81[/eluser] Hi Nick Husher, That's works .. But do u have any idea how to re-populate the gender value when there's a error in validation ?? When i choose the gender = male, but for other field i type in invalid format data. After the validation error message display, gender will reset back to 'Please select a gender type' instead of 'Male'. I know how to do it for input type, but for select box i have no idea Validation Thread - El Forum - 12-18-2007 [eluser]Nick Husher[/eluser] In your view, set up the following code: Code: <?php To do this you need to include the form helper and set your validation library up for field repopulation. Form Helper - scroll to the 'form_dropdown' section Validation - scroll to the 'repopulating the form' section. Validation Thread - El Forum - 12-20-2007 [eluser]cinewbie81[/eluser] Validation question again: What's the validation rules for decimal points in CI?? |