show error on entering special character in node title.

Public

Can you disallow entering special character in node title and show error message.

Get raw version
php
  1. function custom_node_validate($node, $form, $form_state){
  2. // special character list, Add more special character if you want.
  3. $special_character_list = '\'^£$%&*()}{@#~?><>,|=_+¬\-\[\]';
  4. if(preg_match('/[' . $special_character_list . ']/', $node->title, $matches) !== 0){
  5. form_set_error('title', format_string("Special characters !special_character_list are not allowed in title.", array('!special_character_list' => $special_character_list)));
  6. }
  7. }