Welcome Guest, Not a member yet? Register   Sign In
Messages for custom validations?
#1

[eluser]fireproofsocks[/eluser]
This seems like it's a long standing issue... (see http://ellislab.com/forums/viewthread/44627/ ) I've written some custom validation functions, e.g.

Code:
class MY_Form_validation extends CI_Form_validation {
//...
    function is_alpha_dash_extended($str)
    {
        if ( preg_match("/[^0-9a-zA-Z\.,!#\/\(\)\s\-_\[\]']/", $str) )
        {
            $this->CI->form_validation->set_message('is_alpha_dash_extended', 'Input contained invalid characters.');
            return FALSE;
        }
        else
        {
            return TRUE;
        }
    }

But the problem is that if multiple fields reference this function, they ONLY get the generic message. You can no longer tell which field used that message. E.g. if my form has 10 fields that used this rule, and 5 of the inputs were invalid, the user would see 'Input contained invalid characters.' five times and they'd have to guess which fields were invalid.

Is there a way to get the field name in the error message?


Messages In This Thread
Messages for custom validations? - by El Forum - 03-02-2010, 06:20 PM
Messages for custom validations? - by El Forum - 03-02-2010, 06:30 PM
Messages for custom validations? - by El Forum - 03-03-2010, 06:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB