views:

153

answers:

1

Hi,

I'm using prototype and needs to call my function after succesfull validation.

Part of the code:

var validator  = new Validation(this.form);

this will validate the form, but I don't know how to call my function trackForm after the validation is correct and the form is submited.

Any help?

A: 

I would need more details to answer, at least will try then. I assume you're using PrototypeJS - the library. This lib does not support validation by default so you're probably using another library for that.

If you're using Dexagogo's validation (http://tetlaw.id.au/view/javascript/really-easy-field-validation) you will need to use onFormValidate callback.

I never used it, but presume you basically setup Validation like normally, with addition of that extra attribute. Like this:

var validator = new Validator(this.form, {onFormValidate: trackForm});
var trackForm = function (validationPassed, form) {
  if (validationPassed) {
    form.reset();
  }
}

Ofc you don't need to create trackForm, but written as you mentioned about it.

Hope this somewhat helps.

Tomasz Durka