to all guru
i have a validation here which will be very strict in entering a postal code
when first character is 0 or not numeric not allowed
when it is lsser than 6 not valid
when first four characte is not number not valid
when last 2 characters is not character(a-z) not valid <-- i am stuck here
i have this in my form
<type="text" name="zipcode" size='7' maxlength='7">
now when click on submit
this is my script
if (empty($_POST['zipcode']))
$zipcode=$str_error_zip;
else
{
$zip=$_POST['zipcode'];
if ($zip{0}==0)
$zipcode=$str_error_zip_not_valid;
else
{
if ((strlen($zip)==7) || (strlen($zip)==6) )
{
$zip1=substr($zip,0,4);
$zip2=substr($zip,4,7);
if (!is_numeric($zip1))$zipcode=$str_error_zip_digit_valid;
if (is_numeric($zip2))$zipcode ="2nd digit is not valid<br>"; // now i am stuck here
}else{
$zipcode=$str_error_zip_not_valid;
}
}
}
how can i detect if the last 2 character is just (a-z) no space allowed and not number