Trim leading and trailing spaces from Node Title before saving into database , set character length for node title

Public

Get raw version
php
  1. function mymodule_form_form_id_alter(&$form, &$form_state) {
  2. $form['title']['#maxlength'] = 255;
  3. $form['#validate'][] = '_mymodulename_custom_form_validate';
  4. }
  5.  
  6. function _mymodulename_custom_form_validate(&$form, &$form_state) {
  7. $form_state['values']['title'] = trim($form_state['values']['title']);
  8. }

Comments