Validate function not working in ajax form I used Ajax in a form so that submission of form does not lead to reload of the page.It is working . But the problem is 'The Validation code is not working'. This is the code I have used in the form.

This is the code for submit button.

$form['submit'] = array(
  '#type' =&gt; 'submit',
  '#ajax' =&gt; array(
    'callback' =&gt; 'submit_driven_callback',
    'wrapper' =&gt; 'myform',
    'method' =&gt; 'replace',
    'effect' =&gt; 'fade',
  ),
  '#value' =&gt; t('Submit'),
);


I have put the validation part in the following function.

function formname_validate($form, &amp;$form_state) {
  // Validation code
}


Am I doing it the wrong way? Should I put the validation part somewhere else?
You can try the following code.

$form['submit']['#validate'] = array('YOUR_VALIDATE_FUNCTION_NAME');