![]() |
Validation: How to change CSS-style in case of error - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html) +--- Thread: Validation: How to change CSS-style in case of error (/thread-9540.html) |
Validation: How to change CSS-style in case of error - El Forum - 06-29-2008 [eluser]Benedikt[/eluser] Hi, Im using CI for developing a registration-procedure. So far no problems, Im using a lot of helpers already and it works quite well up to now. But I cant figure out how to solve one problem: When the input-data is validated I want, in case of error, to re-display the form with the filled in data which is no problem so far, but the fields who caused an error should be framed in red. Is there a way to use the helpers to make this happen or do I have to code it by myself without CI? You have a hint for me how to solve this? My problem in short: 1) Submit form 2) If Name is e.g. numeric (12345) then throw an error 3) Display form again where the field "Name" has another CSS-style (border:1px #FF0000). Thanks for your help!!! Validation: How to change CSS-style in case of error - El Forum - 06-29-2008 [eluser]sikkle[/eluser] More than one solution for that, honestly, you should use JS to handle that. Second option is to duplicate css code, look if $this->validation->name got a value and class=<?php echo '1pixform'; ?>. More complete solution will be to if else all that if you want to control them all, OR create a helper who echo what you need there to always use it everywhere like change_css_class('name'); Good luck ! Validation: How to change CSS-style in case of error - El Forum - 06-29-2008 [eluser]Benedikt[/eluser] Hi, Thanks for your help. I used simple if-clauses as I can re-use the code this way if the submission was ok. Thanks for your help, Benedikt |