Created
August 15, 2014 09:15
-
-
Save msankhala/e03e2071293e1073ea2b to your computer and use it in GitHub Desktop.
Show error on node title special character.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function custom_node_validate($node, $form, $form_state){ | |
// special character list, Add more special character if you want. | |
$special_character_list = '\'^£$%&*()}{@#~?><>,|=_+¬\-\[\]'; | |
if(preg_match('/[' . $special_character_list . ']/', $node->title) !== 0){ | |
form_set_error('title', t("Special characters !special_character_list are not allowed in title.", array('!special_character_list' => $special_character_list))); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment