Welcome Guest, Not a member yet? Register   Sign In
Validation class: alpha-dash-comma - ?
#1

[eluser]tinawina[/eluser]
Hi -

I have a tag class that runs our site's tagging utility. I want to allow people to add tags that include alphanumeric characters, dashes and underscores which the validation class already let's me do easily via "alpha-dash". We are separating tags (which can be phrases, etc.) with a comma. So I want submissions to include not only alphanumeric characters, dashes, and underscores but also commas.

I went into the validation library to see if there was an easy way to do this. Here's the validation library method for alpha-dash:

Code:
function alpha_dash($str)
{
    return ( ! preg_match("/^([-a-z0-9_-])+$/i", $str)) ? FALSE : TRUE;
}

Of course, I was hoping this would be as easy as just adding a related error message in the validation_lang file, and then adding a new method to the validation library like so:

Code:
function alpha_dash_comma($str)
{
    return ( ! preg_match("/^([-a-z0-9_-,])+$/i", $str)) ? FALSE : TRUE;
}

But I get this error message:

Quote:"Message: preg_match() [function.preg-match]: Compilation failed: range out of order in character class at offset 13"

Anybody have any clues re: why I'm getting this error and what I need to do to make this change? Any help - much appreciated!


Messages In This Thread
Validation class: alpha-dash-comma - ? - by El Forum - 12-20-2007, 03:45 PM
Validation class: alpha-dash-comma - ? - by El Forum - 12-20-2007, 04:24 PM
Validation class: alpha-dash-comma - ? - by El Forum - 12-20-2007, 04:30 PM
Validation class: alpha-dash-comma - ? - by El Forum - 12-20-2007, 05:41 PM



Theme © iAndrew 2016 - Forum software by © MyBB