Module of the Day: Field Validation
Add Comment
Bookmark/Search this post with:
Delicious Delicious
Digg Digg
StumbleUpon StumbleUpon
Facebook Facebook
Google Google
Yahoo Yahoo
Technorati Technorati
Thursday, May 19, 2011
By admin
Write complex validation rules for your fields

Field Validation is a new arrival to the Drupal module directory: its 1st release was just a week ago, and it’s designed for Drupal 7’s new Field API. What does it do? Field Validation allows you to add simple validation rules to custom Drupal fields, using a simple UI.
The module was inspired by Webform Validation, which adds similar validation to WebForm components. Right now, only basic regular expression validation rules are supported support but the module provides hooks for implementing other validation rules.
One common application is enforcing a certain format for information entered into a text field. Product codes or employee ID numbers are common examples. In the instructions below, we’ll assume that the “id_number” field needs to be restricted to ’12-abcd’ style entries — two numbers, a dash, then four letters.
First, create a textfield field called id_number and edit the field. Then, add a new Regular Expression validation rule.

Leave a Reply

Your email address will not be published. Required fields are marked *