Hook form alter to check date field is empty or not First of all I'm new to custom modules, I'm using hook_form_alter to do some custom validation, in the middle I have to check if a date field is empty or not, if empty I will display an error message.

Problem: 
I don't know how to get the value from date field after a form is submitted and check it with empty() function.

I have tried:

$form_state['input']['field_start_date']['und'][0]['value']
$form['field_start_date']['und'][0]['#default_value']['value']
$form_state['values']['field_start_date'] # no use of these.


What am I doing wrong?
The last one should be correct if the form has a field called field_start_date.

You fetch values from the form_state like this:

$form_state['values']['FIELD_NAME'];


To see which values are available in the form_state you can use the devel module to print the values from the form state using dpm($form_state['values']).

UPDATE: You can't really use drupal_set_message() to print arrays, you must use dpm, kint, print_r or other functions that allows you to debug an array.

You can use e.g dpm($form_state['values']['field_start_date']) to see where the values live.