Custom validation for a custom field in comment form I'm currently trying to set up a custom validation script to prevent spam on a comment form with hidden elements.  The problem involves setting up the conditional for the submitted form values.  I'm currently using the hook_form_FORM_ID_alter.  Here is my existing code.

function STARTERKIT_form_comment_node_contact_page_form_alter(&amp;$form, &amp;$form_state) {
    $form['#validate'][] = 'comment_validation_function';
}

function comment_validation_function($form, &amp;$form_state)
{
    if ($form_state['values']['field_website'] != 'http://') {
        form_set_error('field_website', t('Please do not change the value of this field.'));
    }
}


The problem is that $form_state['values']['field_website'] isn't returning the value inside the text field.  I've looked at so many pages showing a script very similar to this, yet I haven't been able to get this even close to working.

The field id is "field_website".
Assuming the field is a text type (and your site is monolingual) you'll find the value here:

$form_state['values']['field_website'][LANGUAGE_NONE][0]['value']


There's an explanation here.

Instead of doing this, though, you might want to have a look at the Field Validation module, which will let you add the same validation rule through the UI.