Disabled date field on node form stops it from saving I have a date field on a drupal node edit form using the pop-up calendar widget. When certain things happen on my site I have to disable some fields on that node edit form, including the date.

However, when this happens, I can no longer save the form because I get this message:


  The value input for field [my field] is invalid.


I tried changing the widget to plain text, and it works fine, so it is an issue with the pop-up calendar widget.

Any ideas?
If using hook_form_alter you can use #limit_validation_errors to exclude that field from validation.


  The #limit_validation_errors property is a list of "sections" within
  $form_state['values'] that must contain valid values. Each "section"
  is an array with the ordered set of keys needed to reach that part of
  $form_state['values'] (i.e., the #parents property of the element).


Example 1: Allow the "Previous" button to function, regardless of whether any user input is valid.

  $form['actions']['previous'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Previous'),
    '#limit_validation_errors' =&gt; array(),       // No validation.
    '#submit' =&gt; array('some_submit_function'),  // #submit required.
  );


Example 2: Require some, but not all, user input to be valid to process the submission of a "Previous" button.

  $form['actions']['previous'] = array(
    '#type' =&gt; 'submit',
    '#value' =&gt; t('Previous'),
    '#limit_validation_errors' =&gt; array(
      array('step1'),       // Validate $form_state['values']['step1'].
      array('foo', 'bar'),  // Validate $form_state['values']['foo']['bar'].
    ),
    '#submit' =&gt; array('some_submit_function'), // #submit required.
  );


More info: form_set_error