SQL PHP HTML ASP JavaScript articles and free scripts to download
PHP Form Form post back

Validating only alphabetic characters by ctype_alpha

By using ctype_alpha function in php we can check or validate alphabetic characters only. Using this function we can check any input coming from insecure ( or any other ) sources. This function is case insensitive so can't differentiate between lower case and upper case alphabetic characters. Here is the syntax of this function.
bool ctype_alpha($text)
Now let us try with some examples.
$var="AbCDef";
if(ctype_alpha($var)){
echo " This is alphabetic ";
}else{ echo "this is not alphabetic";}
By changing the value of $var you can check this function.
We can check user input from a form for presence of alphabets only, here is the sample code.
if(ctype_alpha($_POST['var'])){
echo " This is alphabetic ";
}else{ echo "this is not alphabetic";}
To check only alphanumeric characters we can use ctype_alnum function.

Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer