Validating CCK Form Fields
Submitted by amitsedai on Mon, 07/01/2013 - 15:30Custom validations with form error set on CCK may require custom coding. This is one such exercise for both Drupal 6 and Drupal 7.
Drupal 6
<?php
/**
* Validations for Employee Leave
*/
function custom_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($op == 'validate' && $node->type == 'lms') {
$start_date =$node->field_lms_start_date[0]['value'];
$end_date =$node->field_lms_end_date[0]['value'];
if($start_date > $end_date){
form_set_error('field_lms_start_date', 'Start Date of Leave Should be less than End Date of Leave');
}
}
}
?>