Commit 19c87470 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files
parent 740bedc1
......@@ -109,4 +109,25 @@ var QfqNS = QfqNS || {};
return document.forms[this.formId].checkValidity();
};
/**
* @public
*/
n.Form.prototype.getFirstNonValidElement = function () {
var index;
var elementNumber = document.forms[this.formId].length;
for (index = 0; index < elementNumber; index++) {
var element = document.forms[this.formId][index];
if (!element.willValidate) {
continue;
}
if (!element.checkValidity()) {
return element;
}
}
return null;
};
})(QfqNS);
......@@ -309,6 +309,15 @@ var QfqNS = QfqNS || {};
if (this.form.validate() !== true) {
this.form.$form.validator('validate');
var element = this.form.getFirstNonValidElement();
if (element.hasAttribute('name')) {
var tabId = this.bsTabs.getContainingTabIdForFormControl(element.getAttribute('name'));
if (tabId) {
this.bsTabs.activateTab(tabId);
}
}
var alert = new n.Alert("Form is incomplete.", "warning");
alert.show();
return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment