SQL PHP HTML ASP JavaScript articles and free scripts to download
 
 

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";}

Discuss this tutorial at forum


Further readings
All form components validation with post back and data locking
Checkbox
How to retain form data if validation fails?
How to retain data of a text box after submitting
Retaining status of a check box
Updating checkbox value from & to a table record.
Retaining selected data of a period button of a form
Retaining selected data of a drop down list box of a form
Validating Date: Checking if date exist
Email address validation in a form
PHP Form Validation
is_numeric to check numeric numbers
ctype_alnum to check alphanumeric characters data
ctype_alpha to check alphabetic characters data
How to take care of form & query string variables if Register global is OFF?














 

Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.

Scripts
PHP
JavaScript
PHP Tutorial Index
Popular Tutorials
Drop down list
File Upload
Signup script
Member Login
Line Graph
PHP MySQL Paging
PHP Calendar
PHP Tutorials
Date & Time
Array
String Functions
Math Functions
Form Handling
File Handling
Comment Posting
Content Management
Subscribe
Submit your email address and receive article and product notifications. Your email is safe with us.