Validation error messages below or beside fields |
Hi CI community,
I have a simple question, but I can't produce the answer however I tried to think of it. Here is my scenario: I have a registration form. So users fill it out. Now, if the validation criteria was not satisfied, the form will show validation errors right? Code: <?php echo validation_errors(); ?> Now, here is what I want to accomplish. I want to show the error for each field, just below the field. For example, I have a validation rule for the username, that it must be at least 6 characters long. If the user inputs 4 characters only, I want the error to show just below the field. So if I have error messages for username field and password field, the error messages for the username field will show below the username field, and the error messages for the password field will show below the password field. at the same time. Now, here's a solution I am thinking but I don't know if it is the right way. I will just set a flashdata for each field? and if it is set, I will just show it like this: Code: if ($username < 6) { And then create a span element below the username field: Code: if ($this->session->flashdata('is_less_than_six')) { Is that a good solution? We know it will work, but how about repopulation the fields? Hope you can guide me guys. I want to make my validation errors understandable to the users. Thankyou. Cheers! -Dan
Hi CI Community,
I have already found the answer in the CI Documentation. Showing Errors Individually I learned that reading the documentation thoroughly must be the first thing to do!
Correct
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |