Welcome Guest, Not a member yet? Register   Sign In
User defined error message do not work
#1

[eluser]Zombie1[/eluser]
I'm having some trouble designing my user defined error messages. My 'required' error messages work fine.

Code:
$this->form_validation->set_rules('callback_show_error_message', 'username', 'Username');
$this->form_validation->set_rules('username', 'Username', 'required');
$this->form_validation->set_rules('password', 'Password', 'required');

As you can see the two fields that use 'required' work fine whenever a user leaves a textfield blank an error is displayed.

It's just my own error message that doesn't display. Here's the function:

Code:
function show_error_message()
{
        // Display error message.
        $this->form_validation->set_message('show_error_message', 'Username or password are incorrect');
       return false;
}

If anyone has any ideas then please let me know.
#2

[eluser]Tim Brownlaw[/eluser]
I have an idea... Go and read Form Validation and read the section on callbacks.

That will answer your question.
#3

[eluser]Zombie1[/eluser]
Thanks but I've already read it and copied it but it still doesn't work.
#4

[eluser]treenef[/eluser]
You need to display the validation errors...

<?php echo validation_errors(); ?>
#5

[eluser]rm_beginner[/eluser]
Code:
$this->form_validation->set_rules('callback_show_error_message', 'username', 'Username');

try to put your callback right side.

Code:
$this->form_validation->set_rules( 'username', 'Username', 'callback_show_error_message');

hope it works.
#6

[eluser]Tim Brownlaw[/eluser]
[quote author="rm_beginner" date="1403694854"]
Code:
$this->form_validation->set_rules('callback_show_error_message', 'username', 'Username');

try to put your callback right side.

Code:
$this->form_validation->set_rules( 'username', 'Username', 'callback_show_error_message');

hope it works.[/quote]

That's how it's written in the user guide!

@zombie1.... I'd seriously be reading it again and checking it against what you have written.




Theme © iAndrew 2016 - Forum software by © MyBB