function validText ( $input, $min = null, $max = null )
{   
    if ( !empty($min) && !empty($max) ) {
        $text = "^[a-zA-Z\s0-9]{$min,$max}+$";
    } else {
        $text = "/^[a-zA-Z\s0-9]+$/"; 
    }
    if ( preg_match( $text, $input ) )
    {
        return true;
    }
    else
    {
        return false;
    }
}
whats the problem ? sorry newbie problem