Welcome Guest, Not a member yet? Register   Sign In
Form validation regex_match
#2

[eluser]Matalina[/eluser]
The regex string is not properly formatted

Code:
function regex_match($str, $regex)
{
  if ( ! preg_match($regex, $str))
  {
   return FALSE;
  }

  return  TRUE;
}

so I think you need to do

Code:
$this->form_validation->set_rules('name','Name','required|regex_match[/[a-zA-Z]|\s/]|xss_clean');

Tho that is only going to match the first character.
Code:
$this->form_validation->set_rules('name','Name','required|regex_match[/([a-zA-Z]|\s)+/]|xss_clean');

And if you add in extra characters it's still going to pass.
Code:
$this->form_validation->set_rules('name','Name','required|regex_match[/^([a-zA-Z]|\s)+$/]|xss_clean');

That should match only alpha characters and space.


Messages In This Thread
Form validation regex_match - by El Forum - 06-29-2012, 10:08 AM
Form validation regex_match - by El Forum - 06-29-2012, 10:20 AM
Form validation regex_match - by El Forum - 06-29-2012, 10:34 AM
Form validation regex_match - by El Forum - 06-29-2012, 10:36 AM
Form validation regex_match - by El Forum - 06-29-2012, 10:43 AM
Form validation regex_match - by El Forum - 06-29-2012, 10:46 AM
Form validation regex_match - by El Forum - 06-29-2012, 10:46 AM
Form validation regex_match - by El Forum - 06-29-2012, 10:48 AM
Form validation regex_match - by El Forum - 06-29-2012, 03:55 PM



Theme © iAndrew 2016 - Forum software by © MyBB