Jump to content

validation problem


slanton

Recommended Posts

I am using this to validate

...elseif ($firstName==""or !ereg("^[A-Za-z' -]{1,30}$",$firstName)){
$message = "Please enter a valid Name";
}

and if I enter a name and then a tag it catches the error eg "Frank</" is not allowed. But if I enter

"Frank&</" it doesn't catch the error although the data is entered into the database as "Frank" which is weird. Why does it do that?

Link to comment
https://forums.phpfreaks.com/topic/68342-validation-problem/
Share on other sites

Well yes that does work but that is pretty much what I have already except I want to also allow a space, a hyphen and an apostrophe so I use

!ereg("^[A-Za-z' -]{1,30}$",$firstName))

My reading of that is that it would allow uppercase and lowercase letters spaces, hyphens and  apostrophes. But it also allows the use of & ...and once the & is used it allows the use of < and / etc.If I don't use the & it doesn't allow < or/.

So my question really is why dose the above expression allow the use of & and how can I exclude it?

Link to comment
https://forums.phpfreaks.com/topic/68342-validation-problem/#findComment-343932
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.