diff --git a/maxlength.module b/maxlength.module
index 5f64e33..2473fbb 100644
--- a/maxlength.module
+++ b/maxlength.module
@@ -168,7 +168,7 @@ function maxlength_process_element($element, &$form_state) {
  */
 function maxlength_validate_input(&$element, &$form_state) {
   // Verify that the value is not longer than #maxlength characters.
-  if (isset($element['#attributes']['maxlength'])) {
+  if (isset($element['#attributes']['maxlength']) && isset($element['#value'])) {
     // Compute the length of the text, without counting the tags, and consider
     // the "enter" characters as only one character.
     $value = filter_xss(str_replace(array("\r\n", '&nbsp;'), array(' ', ' '), $element['#value']), array());
@@ -234,4 +234,4 @@ function maxlength_node_title_validate($element, &$form_state, $form) {
    if (!empty($element['#value']) && is_numeric($element['#value']) && $element['#value'] > 255) {
      form_error($element, t('Note titles can be maximum 255 characters long.'));
    }   
-}
\ No newline at end of file
+}
