rickharrison/validate.js — Issue #11: have the callback utilize a return value
Author: nefiga
Created: 2011-12-19 19:54:37+00:00
State: open

it would be about 1000 times cooler if the callback returned a boolean which was used to indicate whether or not the form submit should take place.

Instead of

if (typeof this.callback === 'function') {
this.callback(this.errors, event);
}
if (this.errors.length > 0) {

do something like

var return_value = true;
if (typeof this.callback === 'function') {
return_value = this.callback(this.errors, event);
}
if (this.errors.length > 0 || return_value === false) {

that would really help when you do various ajax-y type of validation and form submits