Welcome Guest, Not a member yet? Register   Sign In
Validation: How to change CSS-style in case of error


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!!!

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 !

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,

Theme © iAndrew 2016 - Forum software by © MyBB