Facebook

Wednesday, July 6, 2011

Decimal validation using codeigniter form validation class | DSCRIPTS

Decimal validation using codeigniter form validation class | DSCRIPTS: "class MY_Form_validation extends CI_Form_validation {
 
    function decimal($value)
    {
        $CI =& get_instance();
        $CI->form_validation->set_message('decimal',
            'The %s is not a valid decimal number.');
 
        $regx = '/^[-+]?[0-9]*\.?[0-9]*$/';
        if(preg_match($regx, $value))
            return true;
        return false;
    }
}"

No comments:

Post a Comment