Showing posts with label email validation in Codeigniter Form Module. Show all posts
Showing posts with label email validation in Codeigniter Form Module. Show all posts

Tuesday, March 4, 2014

Email validation in Codeigniter Form Module

For email validation in Codeigniter Form Module

You may use  valid_email () function of $this->load->helper('email') library

PHP Script:

$this->form_validation->set_rules('email', 'Email', 'required|callback_valid_mail');



public function valid_mail()
            {
           
                        $email = $this->input->post('email');
                        $this->load->helper('email');

                        if (valid_email($email)) {
                                    return TRUE;
                         }else{
                                    $this->form_validation->set_message('valid_mail', 'Email ID is Invalid!!');
                                    return FALSE;
                         }

            }