Jump to content

string checking issue


vijdev

Recommended Posts

I need to ensure a certain field input is:

1.having both alphabets and numerics

2.begins with uppercase alpha

3.must be min. 5 and max 10 characters in all.

 

I am using ^[A-Z]{1}[A-Za-z0-9]{4,9}, but here are the drawbacks:

1.It does not mandate that a number exists in the input, it only ensures it is alphanumeric

2.ctype_alnum along with above regex also does not work.

3.I dont want to mandate that the numbers are only after the alphas(exception of 1st upper case alpha)

 

Link to comment
https://forums.phpfreaks.com/topic/203925-string-checking-issue/
Share on other sites

$input= "King623456789";
$basic_check = preg_match("/^[A-Z]{1}[A-Za-z0-9]{4,9}/", $input, $inputComponents);
$checknum= preg_match("/[0-9]/", $input, $numComponents);   
if ($myDate){
    if($checknum){
        echo "All Ok!";
    }
    else echo "no number";
    
}
else echo "absolutely no match!";

 

anyone any comments?

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.