I am using a custom validation in my Drupal 7 comment form.
I want to match the comment_body
against a word "example"
so if someone just type "example"
in the comment body then it will show a error message that only the word "example"
is not allowed. After reading drupal api documentation i codded like this:
function mango_form_comment_node_news_form_alter(&$form, &$form_state, $form_id){ $form['comment_body']['#prefix'] = '<div class="sm">Post your comment now!</div>'; $form['actions']['submit']['#value'] = 'Post Your Comment'; $form['#validate'][] = 'banana'; } function banana($form, &$form_state) { if ($form_state['comment_body'] == "example") { form_set_error('comment_body', 'Your comment can not contain example!'); } }
Do not working :'(
what i’m missing? Thanks
Sponsored by SupremePR