Jump to content

Validate a textbox for alphabetic character only


Terfanda

Recommended Posts

[!--quoteo(post=385948:date=Jun 20 2006, 01:47 PM:name=Orio)--][div class=\'quotetop\']QUOTE(Orio @ Jun 20 2006, 01:47 PM) [snapback]385948[/snapback][/div][div class=\'quotemain\'][!--quotec--]
if (!eregi("^[a-z]+$",$name)
{die("Invalid name");};
[/quote]
according to your syntax that you gave i tried to write this
function check_Name($Name,$FamName)
{
if ((!eregi("^[a-z]+$",$Name))||(!eregi("^[a-z]+$",$FamName)))
{
$ans=FALSE;
}
else
{
$ans=TRUE;
}
return $ans;

}


but it is still taking numbers can you tell me if the code up is wrong please thank you
Strange it works for me!:[code]<?php

function check_Name($Name, $FamName)
{
    if ((!eregi("^[a-z]+$",$Name)) || (!eregi("^[a-z]+$",$FamName)))
    {
        $ans = FALSE;
    }
    else
    {
        $ans = TRUE;
    }
    return $ans;
}

if(check_Name('j0hn', 'w3lls'))
{
    echo "valid!";
}
else
{
    echo "invalid!";
}

?>[/code]
With numbers it echos invalid, without - john wells - its valid.

How are you checking whether the function returns true or false?

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.