Hi all!
I'm new here!
I was wondering how I can check if a string contains only "A-Za-z0-9_" and ".".
I tried the following code
[php]
function check_validstri ng($check_valid string)
{
if(eregi('[A-Za-z0-9_.]',$check_valids tring))
{
return true;
}
else
{
return false;
}
[/php]
The result is:
When $check_validstr ing = 'aaa' it passed.
When $check_validstr ing = '@@' it failed.
But When $check_validstr ing = 'aaa@@' it passed.
Any way to prevent this? Thanks!
I'm new here!
I was wondering how I can check if a string contains only "A-Za-z0-9_" and ".".
I tried the following code
[php]
function check_validstri ng($check_valid string)
{
if(eregi('[A-Za-z0-9_.]',$check_valids tring))
{
return true;
}
else
{
return false;
}
[/php]
The result is:
When $check_validstr ing = 'aaa' it passed.
When $check_validstr ing = '@@' it failed.
But When $check_validstr ing = 'aaa@@' it passed.
Any way to prevent this? Thanks!
Comment