From 53f034eb5f2b929223100b267805d38552a3e1ee Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 2 Oct 2014 18:06:35 +0200 Subject: [PATCH] Added validation for framework forms. --- .../app/lib/base/jquery.contenteditable.js | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js index d5a1e9d22..9238c0805 100644 --- a/app/assets/javascripts/app/lib/base/jquery.contenteditable.js +++ b/app/assets/javascripts/app/lib/base/jquery.contenteditable.js @@ -217,12 +217,27 @@ length = length + 1 } if ( length > this.options.maxlength ) { - this.$element.addClass('invalid') - setTimeout($.proxy(function(){ - this.$element.removeClass('invalid') - }, this), 1000) - return false + // try to set error on framework form + parent = this.$element.parent().parent() + if ( parent.hasClass('form-group') ) { + parent.addClass('has-error') + setTimeout($.proxy(function(){ + parent.removeClass('has-error') + }, this), 1000) + + return false + } + + // set validation on element + else { + this.$element.addClass('invalid') + setTimeout($.proxy(function(){ + this.$element.removeClass('invalid') + }, this), 1000) + + return false + } } return true }