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
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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.