Return to Snippet

Revision: 29062
at July 20, 2010 14:29 by myke


Initial Code
function alpha_dash_space($str)
	{
            if (! preg_match("/^([-0-9])+$/i", $str))
            {
                $this->form_validation->set_message('alpha_dash_space', 'The %s field may only contain numeric characters and dashes.');
                return FALSE;
            }
            else
            {
                return TRUE;
            }
	}

Initial URL

                                

Initial Description
run as callback from form_validation->setrules
ex:
$this->form_validation->set_rules('cc_number','Credit Card #','required|max_length[20]|callback_alpha_dash_space');

Initial Title
Codeigniter Numeric Dash Validation

Initial Tags
form, validation, codeigniter

Initial Language
PHP