# Available Validation Rules

The PHP validation script comes with functions for all commonly needed validation tasks - things like ensuring email addresses are valid, fields are required and so forth. You can run multiple tests on a single field if you need. To give you an idea of what validation rules available, give the following table a quick look over. In the next step we'll start working on adding some of these rules to validate a simple form.

**required**

field must be filled in

**digits_only**

field must contain digits only

**length=X**

field has to be X characters long

**length=X-Y**

field has to be between X and Y (inclusive) characters long

**length>X**

field has to be greater than X characters long

**length>=X**

field has to be greater than or equal to X characters long

**length<X**

field has to be less than X characters long

**length<=X**

field has to be less than or equal to X characters long

**valid_email**

field has to be valid email address

**same_as**

fieldname is the same as fieldname2 (for password comparison)

**range=X-Y**

field must be a number between the range of X and Y inclusive

**range>X**

field has to be a number greater than X

**range>=X**

field has to be a number greater than or equal to X

**range<X**

field has to be a number less than X

**range<=X**

field has to be a number less than or equal to X

**is_alpha**

field has to be an alphanumeric character (anything between 0-9, a-Z)

**letters_only**

field has to be a letter, a-Z

**custom_alpha**

This option is a layman's version of the

**reg_exp**rule and offers more control than the**letters_only**rule. It lets you check that a field is formatted in a very specific way - like a specific series of integers and digits.**reg_exp**

field is validated according to a regular expression (programmers only)