Check for URLs - SPAM prevention
Check for required information in multiple fields based on the state of one field
Ensure Two of the Same Value
This can be a useful bit of code to ensure that two fields are filled in with the same value (such as two email address that must match).
Limiting the Total Number of Submissions
PHP snippet for limiting the total number of submissions to a Webform. Note that this is different from limiting the number of submissions
Min/Max Length
Below is a PHP snippet to set the minimum length for a field. If the submitted data for that field is too short a helpful error message is
Require one of two fields be filled out
This code makes it so that a user must fill out one of two possible fields. Requires that an email or phone number is given.
Validate E-mail Addresses
To use Drupal's built-in email validation function for checking email addresses submitted through a web form, it's as simple as this:
Validating Fax Number
The if (strlen(trim($fax)) > 0) { line ensures the number is optional for the end-user.
Validating Name or Last Name
This script basically prevents numbers from being used in a field (or other non-alphabetic characters). This validation does not ensure name
Validating Pincode / Post Code
This validation doesn't ensure pincode is required, it should be ensured by field settings.
Validating URL
This loosely validates a field's value to check that it is a URL.
Validating a Phone Number
United States Phone Number Validation
