How to compare form value in an ajax call I have a date picker in my custom form. 'from_date'. When I change the value in this, I need to call a function and compare the date value with another custom value and need to show a popup using custom plugin alertify. I have been succeeded up to creating an ajax_call_back function. But I'm stuck in retrieving form data and showing the popup. 
...

$form['from_date'] = array(
        '#type' =&gt; 'date_popup',
        '#date_format' =&gt; 'd-m-Y',
        '#ajax' =&gt; array(
            'callback' =&gt; 'check_date',
            'event' =&gt; 'change',
        ),
        '#attributes' =&gt; array('class' =&gt; array('date_popup_frm'),)
    );


....

function check_date($form,$form_state){

//how can I compare the value with $value which I will get after calling an SP

}
I found an answer for me after trying various cases. The below is the call back function which I wrote.

function check_date($form,$form_state){    
 $current_date = $form_state['values']['from_date'];
 $custom_value = sp_call_and_extract_needed_data();
 $error_message = t('your error message');
 $current_path = current_path();
 if (strpos($current_path, 'ajax') !== false) { //if call from ajax
   $commands[] = ajax_command_after('#breadcrumbs',  $error_message);
   return array('#type' =&gt; 'ajax', '#commands' =&gt; $commands);
 } else {
   form_set_error('from_date', $error_message);
 }    
}