I'm currently using clientside_validation on a form that is posted to salesforce...it never touches our site, thus the validation is important.

It's become necessary to fire a few more actions when this form is validated+submitted. I know that jQuery validate has a success callback, but it doesn't appear that it is being utilized by this module.

A search of the issues didn't yield my answer--what is the best method to fire a custom javascript function (In this case I need to push an event to Google Analytics and set a cookie) after the form is validated but before it is submitted?

Thank you!

Comments

Version:6.x-1.9» 6.x-1.x-dev
Status:Active» Fixed

Get the latest dev version. With that version you can do something like this in javascript (just add the javascript on the right page):

//Define a Drupal behaviour with a custom name
Drupal.behaviors.customAddCVSumbitHandler = function (context) {
  $(document).bind('clientsideValidationInitialized', function() {
    Drupal.myClientsideValidation.validators['custom-forms-form-example'].settings.submitHandler = function(form) {
      alert('test');
    };
  });
};

Excellent, thank you!

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Status:Closed (fixed)» Active

@Jelle_S:

I'm reopening this issue with a further request that I think will be quite simple.

I ended up using a different workaround originally, but i've circled back on this project and now need to run an event when success is determined by Clientside Validation. I have a file upload, upon form submission I want to pop an overlay over the whole screen with a message like "Your file is uploading, please wait".

First off: The recent 6.x version doesn't work for me. Everything appears to be configured properly, I get no errors anywhere, settings are set correctly, it simply doesn't execute clientside validation. When I experience this behavior the clientsideValidationInitialized event is firing, and when I look in the myClientsideValidation object the validatiors object does show my node-form validator, which is what I was looking for.

So: I went ahead and just added the clientsideValidationInitialized event into the 6.x.1.32 version just as it was in the dev version, as this version is working for me. I'm fine with using this method, I don't know how to begin debugging the dev version.

My issue: When I do something like this:

<?php
 
$(document).bind('clientsideValidationInitialized', function() {
   
Drupal.myClientsideValidation.validators['node-form'].settings.submitHandler = function(form) {
     
console.log("Submit");
      return
true;
    };
  });
?>

the form won't submit. I'll see the "Submit" in the log, I've tried it with and without the return.

Am I supposed to return a certain value here to get the form to actually submit? This may not be a clientside validation specific question but I just can't get this to work.

Thanks again-

try form.submit();

I'm also trying to hook into success event and to show a message, but can't reach this goal. Various kinds of errors break my code. I've tried the solution provided in comment #1, but I have many troubles with jquery and jquery validate lib versions. Can you please write to me what versions of these two libraries do you use. Thanks!