• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Full name validation in codeigniter

#1
[eluser]Aqsa Jamil[/eluser]
Which validation rule is used to validate full name field in codeigniter.
I need to place a validation rule that full name field should accept space between first name and last name

Can any one help me ????

#2
[eluser]Sanjay Sarvaiya[/eluser]
you can use callback function in validation.
if you have not idea about callback please read this userguide.
http://ellislab.com/codeigniter/user-gui...#callbacks

#3
[eluser]Aqsa Jamil[/eluser]
How to write callback function for checking if user is entering space between first name and last name???

#4
[eluser]Sanjay Sarvaiya[/eluser]
I think you have not read user guide Every things are described on it.
in your case your call back function will be shaw in bellowed Example.
may this help you.
Code:
//set your validation rules
$this->form_validation->set_rules('name', 'Full Name', 'callback_space_check');

your call back function will be like...
public function space_check($str) {
   $pos = strrpos($str, " ");
   if ($pos === false) { // note: three equal signs
    // not found...
    $this->form_validation->set_message('space_check', 'The %s field can not contain SPACE BTW First name and Last Name');
    return FALSE;
  }
  else  {
    return true;
  }
}


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.