title: check a condition before a ajax call back of form in drupal 7
body: <p>I have written ajax callback on a textfield and it is called on blur event.</p>
  
  <p>But before It going for ajax callback I want to check a condition that textfield not empty.</p>
  
  <p>So I want,If textfield is not empty then the ajax callback is get called otherwise it should not get called.</p>
  
  <p>Thanks in advance</p>
  
  <p>form_example is my module name</p>
  
  <p><strong>Form control</strong></p>
  
  <pre><code>$form['price_form']['item'] = array(
      '#type' =&gt; 'textfield',
      '#title' =&gt; 'Item Name?',
      '#size' =&gt; 10,
      '#maxlength' =&gt; 25,
      '#id' =&gt; 'nameId',
      '#required' =&gt; TRUE,
      '#ajax' =&gt; array(
          // #ajax has two required keys: callback and wrapper.
          // 'callback' is a function that will be called when this element changes.
          'callback' =&gt; 'form_example_simplest_callback',
          'wrapper' =&gt; 'listDiv',
          'effect' =&gt; 'fade',
      ),
      '#autocomplete_path' =&gt; 'examples/form_example/item_name_autocomplete_callback',
  );
  </code></pre>
  
  <p><strong>JS Code</strong></p>
  
  <pre><code>(function($){
      $(document).ready(function(){
          alert('Hi, Javascript successfully attached');
  
          Drupal.behaviors.form_example = {
              attach: function (context, settings) {
  
                  // Overwrite beforeSubmit
                  Drupal.ajax['nameId'].options.beforeSubmit = function (form_values, element, options) {
                      alert('dsf');
                  }
              }
          };
      });
  })(jQuery);
  </code></pre>
  
  <p>I am printing alert for testing.I tried by its name and by its id but not getting alert.I got below alert so js inclusion fine. </p>
  
  <pre><code>alert('Hi, Javascript successfully attached');
  </code></pre>