title: How to display confirm box before submitting an AJAX form in Drupal 7?
body: <p>Using Drupal 7 form API, How can I prompt javascript confirm box before submitting an AJAX form? I have tried different possible ways to do this but no success. Here is the code:</p>
  
  <pre><code>function create_list_form($form, &amp;$form_state) {
  
    $form['list_name'] = array(
      '#type' =&gt; 'textfield',
      '#required' =&gt; TRUE,
      '#title' =&gt; 'List Name'
      '#attributes' =&gt; array()
    );
  
    $form['list_desc'] = array(
      '#type' =&gt; 'textfield',
      '#required' =&gt; TRUE,
      '#title' =&gt; 'List Desc'
      '#attributes' =&gt; array()
    );
  
      $form['actions']['submit'] = array(
          '#type' =&gt; 'submit',
          '#attributes' =&gt; array('class' =&gt; array('use-ajax-submit')),            
          '#value' =&gt; 'Create List'
        );
  
  
    return $form;
  }
  </code></pre>
  
  <p>Here is the Javascript code:</p>
  
  <pre><code>Drupal.behaviors.module = {
    attach: function() {
  
         jQuery('#edit-submit').click(function(){
            if(!confirm('Are you sure?'))
                return false;
        });
  
    }
  }
  </code></pre>