|
|
@ -135,12 +135,16 @@ |
|
|
|
data.submitting = true; |
|
|
|
data.submitting = true; |
|
|
|
if (!data.settings.beforeSubmit || data.settings.beforeSubmit($form)) { |
|
|
|
if (!data.settings.beforeSubmit || data.settings.beforeSubmit($form)) { |
|
|
|
validate($form, function (messages) { |
|
|
|
validate($form, function (messages) { |
|
|
|
var hasError = false; |
|
|
|
var errors = []; |
|
|
|
$.each(data.attributes, function () { |
|
|
|
$.each(data.attributes, function () { |
|
|
|
hasError = updateInput($form, this, messages) || hasError; |
|
|
|
if (updateInput($form, this, messages)) { |
|
|
|
|
|
|
|
errors.push(this.input); |
|
|
|
|
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
updateSummary($form, messages); |
|
|
|
updateSummary($form, messages); |
|
|
|
if (!hasError) { |
|
|
|
if (errors.length) { |
|
|
|
|
|
|
|
$(window).scrollTop($form.find(errors.join(',')).first().offset().top); |
|
|
|
|
|
|
|
} else { |
|
|
|
data.validated = true; |
|
|
|
data.validated = true; |
|
|
|
var $button = data.submitObject || $form.find(':submit:first'); |
|
|
|
var $button = data.submitObject || $form.find(':submit:first'); |
|
|
|
// TODO: if the submission is caused by "change" event, it will not work
|
|
|
|
// TODO: if the submission is caused by "change" event, it will not work
|
|
|
|