Alphabetic validation using php?
Friday, September 21st, 2007We can validate a value for alphabets by the following function
| function check_alphabets($str) { // Suresh written for validating alpha values for($i=0;$i<strlen($str);$i++) { $chara=ord($str[$i]); if(!((($chara>96) && ($chara<123))||(($chara>64) && ($chara<91)))) return 0; } return 1; } |
Here is the way to call the function
| if(check_alphabets($_REQUEST[name])<1)$err=”Please enter alphabets” ; |