Custom form not being validated on submission So, I'm trying to implement a Salesforce generated Web-to-Case form on my Drupal site. I have implemented the form correctly so that it updates the Salesforce application cases, but for some reason the form doesn't get validated before submission. I have placed the form in a block with a custom module for portability and versatility. Here is the code for the form. Neither the required fields, nor my attempt to validate the form are enforced before submission. I'm pasting my code below stripped of extraneous fields to for demonstration. 

function web_to_case_form($form, &amp;$form_state){
  $form = array(
'#action' =&gt; 'https://webto.salesforce.com/servlet/servlet.WebToCase?encoding=UTF-8',
);
  $form['lastname'] = array(
  '#id' =&gt; '00N6A000009vWYv',
  '#name' =&gt; '00N6A000009vWYv',
  '#required' =&gt; TRUE,
  '#title' =&gt; t('Last Name'),
  '#type' =&gt; 'textfield',
  '#maxlength' =&gt; 30,
  '#size' =&gt; 20,
  );

   $form['maidenname'] = array(
  '#id' =&gt; '00N6A000009vWYM',
  '#name' =&gt; '00N6A000009vWYM',
  '#title' =&gt; t('Maiden Name'),
  '#required' =&gt; TRUE,
  '#type' =&gt; 'textfield',
  '#maxlength' =&gt; 30,
  '#size' =&gt; 20,
  );

  $form['email'] = array(
  '#id' =&gt; 'email',
  '#title' =&gt; t('Email'),
  '#name' =&gt; 'email',
  '#required' =&gt; TRUE,
  '#type' =&gt; 'textfield',
  '#maxlength' =&gt; 80,
  '#size' =&gt; 20,
  );

   $form['phone'] = array(
  '#id' =&gt; 'phone',
  '#title' =&gt; t('Phone'),
  '#name' =&gt; 'phone',
  '#required' =&gt; TRUE,
  '#type' =&gt; 'textfield',
  '#maxlength' =&gt; 80,
  '#size' =&gt; 20,
  '#element_validate' =&gt; array('element_validate_number '),
   );

  $form['submit'] = array(
     '#type' =&gt; 'submit',
     '#value' =&gt; t('Submit'),
   );
return $form;
}

function web_to_case_form_validate($form, &amp;$form_state) {
  $email = $form_state['values']['email'];
  // Verify that the email address is valid.
  if (!valid_email_address($email)) {
    form_set_error('email', t('You must provide a valid email address.'));
  }
}


Is this because the form is being submitted to an external URL? If that's the case, how to I validate a form before submission? Otherwise, not sure what's going on here. I've even tried to add a validate element to one of the form elements, but that doesn't seem to work either.
Is this because the form is being submitted to an external URL?


Yes, the submit handler for a form in your website won't be executed unless that form is submitted back to your website.


  If that's the case, how to I validate a form before submission?


If you mean server-side (non-JS) validation, and you want the user to continue on to the remote URL as if they'd submitted the form as normal, you can't. There's simply no way to do that.

If you don't need the user to be forwarded on to the remote URL after submission, and the remote website allows it, you could just send a POST request from the submit handler with the data you've received from the Drupal form submission. 

If you're even luckier, they'll have an API you can use instead.