diff --git a/src/js/brutusin-json-forms-bootstrap.js b/src/js/brutusin-json-forms-bootstrap.js index 46fd20a..c178d00 100644 --- a/src/js/brutusin-json-forms-bootstrap.js +++ b/src/js/brutusin-json-forms-bootstrap.js @@ -212,6 +212,14 @@ if (("undefined" === typeof $ || "undefined" === typeof $.fn || "undefined" === BrutusinForms.onValidationError = function (element, message) { setTimeout(function () { + if (element.tagName === "DIV" && element.childElementCount !== 0) { + for (var i = 0; i < element.childElementCount; i++) { + if (element.childNodes[i].tagName === "INPUT") { + element = element.childNodes[i]; + break; + } + } + } var dataToggle = element.getAttribute("data-toggle"); var dataTrigger = element.getAttribute("data-trigger"); var dataContent = element.getAttribute("data-content"); diff --git a/src/js/brutusin-json-forms.js b/src/js/brutusin-json-forms.js index 64b4d34..e4f15ba 100644 --- a/src/js/brutusin-json-forms.js +++ b/src/js/brutusin-json-forms.js @@ -418,6 +418,20 @@ if (typeof brutusin === "undefined") { input.selectedIndex = 2; } } + + input.getValidationError = function () { + try { + var value = getValue(s, input); + if (value === null) { + if (s.required) { + return BrutusinForms.messages["required"]; + } + } + } catch (error) { + return BrutusinForms.messages["invalidValue"]; + } + }; + input.onchange = function () { if (parentObject) { parentObject[propertyProvider.getValue()] = getValue(s, input);