Terfanda Posted June 20, 2006 Share Posted June 20, 2006 Hi All if some one can tell me how to validate a textbox for example Name entry to enter only alphabet character Link to comment https://forums.phpfreaks.com/topic/12453-validate-a-textbox-for-alphabetic-character-only/ Share on other sites More sharing options...
Orio Posted June 20, 2006 Share Posted June 20, 2006 if (!eregi("^[a-z]+$",$name){die("Invalid name");}; Link to comment https://forums.phpfreaks.com/topic/12453-validate-a-textbox-for-alphabetic-character-only/#findComment-47605 Share on other sites More sharing options...
Terfanda Posted June 20, 2006 Author Share Posted June 20, 2006 [!--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 Link to comment https://forums.phpfreaks.com/topic/12453-validate-a-textbox-for-alphabetic-character-only/#findComment-47615 Share on other sites More sharing options...
wildteen88 Posted June 20, 2006 Share Posted June 20, 2006 Strange it works for me!:[code]<?phpfunction 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? Link to comment https://forums.phpfreaks.com/topic/12453-validate-a-textbox-for-alphabetic-character-only/#findComment-47702 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.